Skip to content

std.fmt

padding, justified numbers and joining over io.Writer; number parsing no Display interface: dispatch that passes another interface pointer hits a compiler bug

pub write_padded_left :: fn(w: *Writer, data: []const u8, width: usize, fill: u8) -> usize ! IoError
pub write_padded_right :: fn(w: *Writer, data: []const u8, width: usize, fill: u8) -> usize ! IoError
pub write_padded_center :: fn(w: *Writer, data: []const u8, width: usize, fill: u8) -> usize ! IoError

odd leftover padding goes right

pub write_u64_padded :: fn(w: *Writer, value: u64, width: usize, fill: u8) -> usize ! IoError
pub write_i64_padded :: fn(w: *Writer, value: i64, width: usize, fill: u8) -> usize ! IoError
pub write_hex_u64_padded :: fn(w: *Writer, value: u64, width: usize, fill: u8) -> usize ! IoError
pub join_bytes :: fn(w: *Writer, items: []const []const u8, sep: []const u8) -> usize ! IoError

items separated by sep

pub ParseError :: errors {
empty,
invalid,
overflow,
}
  • empty: no digits
  • invalid: non-digit for the base, or a misplaced sign or _
  • overflow: the number does not fit the type
pub parse_int :: fn($T: type, text: []const u8, base: u8) -> T ! ParseError

any integer T; base 2..36, or 0 to read a 0x/0o/0b prefix; _ allowed between digits

pub parse_float :: fn(text: []const u8) -> f64 ! ParseError

sign, digits, optional . and exponent; inf/infinity/nan; too large -> inf exact for <= 15 digits and |exp| <= 22; beyond that may be off by one ulp