Module fmt/writer
fmt/writer
Chainable string builder for composing formatted output.
Example
{ Writer, Alignment } :: import "std/fmt/writer";
w := Writer.new()
.write_str("hello ")
.write_str("world")
.write_byte(u8(33));
s := w.to_string(); // "hello world!"
Types
Alignment
enum
Alignment
Text alignment for padded output.
Variants
| Variant | Fields | Description |
|---|---|---|
Left | ||
Right | ||
Center |
Writer
object
Writer
Chainable string builder backed by ArrayList(u8).
Useful for constructing formatted strings without intermediate allocations.
Fields
| Name | Type | Description |
|---|---|---|
buf | ArrayList(u8) |
impl(Writer, ...)
new : (Writer) fn() -> WriterCreate a new empty Writer.
Returns: Writer
with_capacity : (Writer) fn(cap : usize) -> WriterCreate a Writer pre-allocated with the given byte capacity.
Parameters
| Name | Type | Notes |
|---|---|---|
cap | usize |
Returns: Writer
write_str : (Writer) fn(self : Writer, s : str) -> Writerwrite_string : (Writer) fn(self : Writer, s : String) -> Writerwrite_byte : (Writer) fn(self : Writer, b : u8) -> Writerwrite_bytes : (Writer) fn(self : Writer, data : ArrayList(u8)) -> Writerwrite_rune : (Writer) fn(self : Writer, r : rune) -> Writerwrite_i64 : (Writer) fn(self : Writer, n : i64) -> Writerwrite_u64 : (Writer) fn(self : Writer, n : u64) -> Writerwrite_f64 : (Writer) fn(self : Writer, n : f64, precision : i32) -> Writerwrite_bool : (Writer) fn(self : Writer, b : bool) -> Writerwrite_hex : (Writer) fn(self : Writer, n : u64) -> Writerwrite_octal : (Writer) fn(self : Writer, n : u64) -> Writerwrite_binary : (Writer) fn(self : Writer, n : u64) -> Writerwrite_padded : (Writer) fn(self : Writer, s : str, width : usize, pad : rune, align : Alignment) -> Writerto_string : (Writer) fn(self : Writer) -> Stringlen : (Writer) fn(self : Writer) -> usize