Module

core::fmt

source

The writer protocol and the printing and formatting traits.

Types

ReadingWriter!A writer that also carries a context that reads a domain's bytes (ReadBytes), so an f-string can interpolate text of that domain directly: every {text} is read through the writer's own context, one context serving any number of parts.
CountingWriterCounts bytes without storing them.

Traits

WriterA destination for bytes: the output protocol that f-strings and Format write to.
FormatFormatting of a T into any writer W, handing the value back.
PrintableA value that can be printed into a writer W; printing uses it up.

Functions

write_u64Writes the decimal digits of n, most significant first.
write_i64Writes the decimal digits of n, after a - when it is negative.
write_f64Writes x as the shortest decimal that reads back as it (see "Floats" in the module notes): 2.5, 0.1, 100, 1e21, 5e-324, -0, inf, -inf, NaN.
write_f32Writes x as the shortest decimal that reads back as it as an f32, as write_f64 does for an f64: 0.1f32 is 0.1.
write_decimalA positive decimal laid out as ECMAScript's Number::toString does: an integer of at most 21 digits in full, a number from 10^-6 on positionally, anything else as d.ddde±x.
write_digitsWrites the digits from to to of the count decimal digits of digits, most significant first.
write_zerosWrites n zeros.

Instances

Format[u8, W]A u8 formats as its decimal digits.
Format[u16, W]A u16 formats as its decimal digits.
Format[u32, W]A u32 formats as its decimal digits.
Format[u64, W]A u64 formats as its decimal digits.
Format[usize, W]A usize formats as its decimal digits.
Format[i8, W]A i8 formats as its decimal digits, after - when negative.
Format[i16, W]A i16 formats as its decimal digits, after - when negative.
Format[i32, W]A i32 formats as its decimal digits, after - when negative.
Format[i64, W]A i64 formats as its decimal digits, after - when negative.
Format[isize, W]A isize formats as its decimal digits, after - when negative.
Format[f64, W]An f64 formats as the shortest decimal that reads back as it (write_f64).
Format[f32, W]An f32 formats as the shortest decimal that reads back as it (write_f32).
Format[bool, W]A bool formats as true or false.
Printable[Str['static], W]'static text, such as a literal, prints as its bytes.
Printable[u8, W]A u8 prints as its decimal digits.
Printable[u16, W]A u16 prints as its decimal digits.
Printable[u32, W]A u32 prints as its decimal digits.
Printable[u64, W]A u64 prints as its decimal digits.
Printable[usize, W]A usize prints as its decimal digits.
Printable[i8, W]An i8 prints as its decimal digits, after - when negative.
Printable[i16, W]An i16 prints as its decimal digits, after - when negative.
Printable[i32, W]An i32 prints as its decimal digits, after - when negative.
Printable[i64, W]An i64 prints as its decimal digits, after - when negative.
Printable[isize, W]An isize prints as its decimal digits, after - when negative.
Printable[f32, W]An f32 prints as the shortest decimal that reads back as it (write_f32).
Printable[f64, W]An f64 prints as the shortest decimal that reads back as it (write_f64).
Printable[bool, W]A bool prints as true or false.
Format[Readable[C, S], W]A borrowed byte view formats as its bytes, read through its capability.
Writer[ReadingWriter![W, C]]Every write goes to the inner writer.
Format[Str['r], ReadingWriter![W, C]]Text formats as its bytes, read through the writer's context: f"{name}".write(&cx, out) with name: Str['k].
Writer[CountingWriter]Each write adds its length to the count.

Function declarations

fn write_u64source

forall W where Writer[W].
fn write_u64(out: W, n: u64) -> W { ... }

Writes the decimal digits of n, most significant first.

fn write_i64source

forall W where Writer[W].
fn write_i64(out: W, n: i64) -> W { ... }

Writes the decimal digits of n, after a - when it is negative.

fn write_f64source

forall W where Writer[W].
fn write_f64(out: W, x: f64) -> W { ... }

Writes x as the shortest decimal that reads back as it (see "Floats" in the module notes): 2.5, 0.1, 100, 1e21, 5e-324, -0, inf, -inf, NaN.

fn write_f32source

forall W where Writer[W].
fn write_f32(out: W, x: f32) -> W { ... }

Writes x as the shortest decimal that reads back as it as an f32, as write_f64 does for an f64: 0.1f32 is 0.1.

fn write_decimalsource

forall W where Writer[W].
fn write_decimal(out: W, decimal: Decimal) -> W { ... }

A positive decimal laid out as ECMAScript's Number::toString does: an integer of at most 21 digits in full, a number from 10^-6 on positionally, anything else as d.ddde±x.

fn write_digitssource

forall W where Writer[W].
fn write_digits(out: W, digits: u64, count: u32, from: u32, to: u32) -> W { ... }

Writes the digits from to to of the count decimal digits of digits, most significant first.

fn write_zerossource

forall W where Writer[W].
fn write_zeros(out: W, n: u32) -> W { ... }

Writes n zeros.

Instance declarations

instance Format[u8, W]source

forall W where Writer[W].
instance Format[u8, W] { ... }

A u8 formats as its decimal digits.

instance Format[u16, W]source

forall W where Writer[W].
instance Format[u16, W] { ... }

A u16 formats as its decimal digits.

instance Format[u32, W]source

forall W where Writer[W].
instance Format[u32, W] { ... }

A u32 formats as its decimal digits.

instance Format[u64, W]source

forall W where Writer[W].
instance Format[u64, W] { ... }

A u64 formats as its decimal digits.

instance Format[usize, W]source

forall W where Writer[W].
instance Format[usize, W] { ... }

A usize formats as its decimal digits.

instance Format[i8, W]source

forall W where Writer[W].
instance Format[i8, W] { ... }

A i8 formats as its decimal digits, after - when negative.

instance Format[i16, W]source

forall W where Writer[W].
instance Format[i16, W] { ... }

A i16 formats as its decimal digits, after - when negative.

instance Format[i32, W]source

forall W where Writer[W].
instance Format[i32, W] { ... }

A i32 formats as its decimal digits, after - when negative.

instance Format[i64, W]source

forall W where Writer[W].
instance Format[i64, W] { ... }

A i64 formats as its decimal digits, after - when negative.

instance Format[isize, W]source

forall W where Writer[W].
instance Format[isize, W] { ... }

A isize formats as its decimal digits, after - when negative.

instance Format[f64, W]source

forall W where Writer[W].
instance Format[f64, W] { ... }

An f64 formats as the shortest decimal that reads back as it (write_f64).

instance Format[f32, W]source

forall W where Writer[W].
instance Format[f32, W] { ... }

An f32 formats as the shortest decimal that reads back as it (write_f32).

instance Format[bool, W]source

forall W where Writer[W].
instance Format[bool, W] { ... }

A bool formats as true or false.

instance Printable[Str['static], W]source

forall W where Writer[W].
instance Printable[Str['static], W] { ... }

'static text, such as a literal, prints as its bytes.

instance Printable[u8, W]source

forall W where Writer[W].
instance Printable[u8, W] { ... }

A u8 prints as its decimal digits.

instance Printable[u16, W]source

forall W where Writer[W].
instance Printable[u16, W] { ... }

A u16 prints as its decimal digits.

instance Printable[u32, W]source

forall W where Writer[W].
instance Printable[u32, W] { ... }

A u32 prints as its decimal digits.

instance Printable[u64, W]source

forall W where Writer[W].
instance Printable[u64, W] { ... }

A u64 prints as its decimal digits.

instance Printable[usize, W]source

forall W where Writer[W].
instance Printable[usize, W] { ... }

A usize prints as its decimal digits.

instance Printable[i8, W]source

forall W where Writer[W].
instance Printable[i8, W] { ... }

An i8 prints as its decimal digits, after - when negative.

instance Printable[i16, W]source

forall W where Writer[W].
instance Printable[i16, W] { ... }

An i16 prints as its decimal digits, after - when negative.

instance Printable[i32, W]source

forall W where Writer[W].
instance Printable[i32, W] { ... }

An i32 prints as its decimal digits, after - when negative.

instance Printable[i64, W]source

forall W where Writer[W].
instance Printable[i64, W] { ... }

An i64 prints as its decimal digits, after - when negative.

instance Printable[isize, W]source

forall W where Writer[W].
instance Printable[isize, W] { ... }

An isize prints as its decimal digits, after - when negative.

instance Printable[f32, W]source

forall W where Writer[W].
instance Printable[f32, W] { ... }

An f32 prints as the shortest decimal that reads back as it (write_f32).

instance Printable[f64, W]source

forall W where Writer[W].
instance Printable[f64, W] { ... }

An f64 prints as the shortest decimal that reads back as it (write_f64).

instance Printable[bool, W]source

forall W where Writer[W].
instance Printable[bool, W] { ... }

A bool prints as true or false.

instance Format[Readable[C, S], W]source

forall C, S, W where ReadBytes[C, S], Copy[S], Writer[W].
instance Format[Readable[C, S], W] { ... }

A borrowed byte view formats as its bytes, read through its capability.

instance Writer[ReadingWriter![W, C]]source

forall W, C where Writer[W].
instance Writer[ReadingWriter![W, C]] { ... }

Every write goes to the inner writer.

instance Format[Str['r], ReadingWriter![W, C]]source

forall W, C, 'r where Writer[W], ReadBytes[C, Str['r]].
instance Format[Str['r], ReadingWriter![W, C]] { ... }

Text formats as its bytes, read through the writer's context: f"{name}".write(&cx, out) with name: Str['k]. A Str['static] in an f-string is written directly, as literal text is.

instance Writer[CountingWriter]source

instance Writer[CountingWriter] { ... }

Each write adds its length to the count.

Blanket methods

method putsource

forall T where Printable[T, W].
fn put(self, x: T) -> W { ... }

In forall W where Writer[W].

Prints x into the writer (Printable), using x up: Buffer!::new().put("line ").put(n).

method writesource

forall C, S where ReadBytes[C, S], Copy[S].
fn write(self, &cx: C, bytes: S) -> W { ... }

In forall W where Writer[W].

Writes the bytes of any readable byte view, read through the capability that permits it. Never consumes the view itself.