Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/fmt"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
ascii |
core/ascii |
fmt.dodo |
float_decimal |
std/float_decimal |
fmt.dodo |
io |
std/io |
fmt.dodo |
mem |
core/mem |
fmt.dodo |
num |
core/num |
fmt.dodo |
ptr |
core/ptr |
fmt.dodo |
text |
std/text |
fmt.dodo |
Alignment
Enum · Source
pub enum Alignment {
Left, Right, Center
}
Sign
Enum · Source
pub enum Sign {
NegativeOnly, Always, Space
}
FloatStyle
Enum · Source
pub enum FloatStyle {
Fixed, Scientific
}
Options
Struct · Source
Width counts output bytes, not Unicode scalars, graphemes, or display columns. Fill must be ASCII. Numeric zero padding follows the sign. Center places an odd extra padding byte on the right. radix must be in 2..=36.
pub struct Options {
pub width: usize
pub fill: u8
pub alignment: Alignment
pub sign: Sign
pub radix: u8
pub uppercase: bool
pub zero_pad: bool
}
defaults
Function · Source
pub fn defaults() -> Options
Formatter
Struct · Source
Statically dispatched byte formatting. W implements the std/io writer contract. No allocation, implicit flush, global locale, or format parser. Each failure reports total bytes emitted by this Formatter, including the failing write’s partial progress. Prior bytes are never rolled back.
pub struct Formatter<W> {
// Private implementation fields omitted.
}
Formatter.new
Function · Source
pub fn new(sink: &mut W) -> Formatter<W> from(sink)
Formatter.written
Function · Source
pub fn written(&self) -> usize
Formatter.bytes
Function · Source
pub fn bytes(&mut self, value: &[u8]) -> void!io.Error
Formatter.string
Function · Source
pub fn string(&mut self, value: &str) -> void!io.Error
Formatter.decimal
Function · Source
Default decimal helpers also form the structural error-formatting contract.
pub fn decimal(&mut self, value: i64) -> void!io.Error
Formatter.natural
Function · Source
pub fn natural(&mut self, value: u64) -> void!io.Error
Formatter.padded_string
Function · Source
pub fn padded_string(&mut self, value: &str, options: &Options) -> void!io.Error
Formatter.boolean
Function · Source
pub fn boolean(&mut self, value: bool, options: &Options) -> void!io.Error
Formatter.codepoint
Function · Source
pub fn codepoint(&mut self, value: u32, options: &Options) -> void!io.Error
Formatter.unsigned
Function · Source
pub fn unsigned(&mut self, value: u64, options: &Options) -> void!io.Error
Formatter.signed
Function · Source
pub fn signed(&mut self, value: i64, options: &Options) -> void!io.Error
Formatter.floating
Function · Source
Precision is mandatory, 0..=324 decimal places. Scientific uses exactly precision digits after its radix point; the exponent has at least 2 digits. Round to nearest, ties to even. Preserve negative zero. Emit inf/nan (or uppercase forms); all NaNs are canonicalized to an unsigned nan spelling.
pub fn floating(&mut self, value: f64, precision: usize, style: FloatStyle, options: &Options) -> void!io.Error
FormatError
Enum · Source
Transactional decimal formatting into caller storage. Width is a minimum; values are never truncated. The full output is checked before the first write.
pub enum FormatError {
BufferTooSmall
}
write_u32_padded
Function · Source
pub fn write_u32_padded(destination: &mut[u8], value: u32, width: usize) -> usize!FormatError
print
Function · Source
These reserved declarations lower to fixed, statically typed functions before normal checking. All output uses one Formatter and preserves io.Error counts. print/println automatically format primitives and borrow custom value places.
@compiler(print)
pub fn print<W, T>(sink: &mut W, value: T) -> usize!io.Error
println
Function · Source
@compiler(println)
pub fn println<W, T>(sink: &mut W, value: T) -> usize!io.Error
printf
Function · Source
printf requires a literal format followed by heterogeneous arguments. {} is automatic; {{ and }} escape braces. Options after ‘:’ are [[fill]align][sign][0][width][.precision][type]; see the formatting reference.
@compiler(printf)
pub fn printf<W>(sink: &mut W, format: &str) -> usize!io.Error
Codepoint
Struct · Source
A codepoint wrapper selects UTF-8 scalar rendering instead of integer output.
pub struct Codepoint {
// Private implementation fields omitted.
}
Codepoint.format
Function · Source
pub fn format<W>(&self, output: &mut Formatter<W>) -> void!io.Error
codepoint
Function · Source
pub fn codepoint(value: u32) -> Codepoint