Basic module

builder_to_string

procedureSource

The text in builder as a new string, allocated with the context allocator (not the builder's). You free it. The builder is emptied afterwards unless do_reset is false. extra_bytes_to_prepend leaves that many unwritten bytes in front of the text. A failed builder gives an empty string.

builder_to_string :: (
    builder: *String_Builder,
    extra_bytes_to_prepend := 0,
    do_reset := true
) -> string

Parameters

builder: *String_Builder
extra_bytes_to_prepend := 0
do_reset := true

Returns

string
Example↗
builder: String_Builder;
append(*builder, "total: ");
print_to_builder(*builder, "%", 42);
text := builder_to_string(*builder);
defer free(text);
assert(text == "total: 42");

See also