Module
pooka/string_tree
src/pooka/string_tree.pookaKeep the pieces until somebody asks for the whole parcel. Appending makes a branch in constant time. Rendering walks an explicit work list, preserving chunk order without recursive calls down a deep left spine. Text stays UTF-8; byte counts describe encoding, not visible characters.
assert string_tree.to_string(string_tree.from_string("oak")) == "oak"
API reference
class StringTree
An immutable tree. Only the private leaf and branch classes construct its values.
new() -> StringTree
fn() -> pooka/string_tree.StringTreeStart without any chunks.
from_string(value: String) -> StringTree
fn(String) -> pooka/string_tree.StringTreeKeep a chunk without copying its contents.
append(tree: StringTree, value: String) -> StringTree
fn(pooka/string_tree.StringTree, String) -> pooka/string_tree.StringTreeAttach one chunk in constant time.
assert string_tree.to_string(string_tree.append(string_tree.new(), "oak")) == "oak"
append_tree(left: StringTree, right: StringTree) -> StringTree
fn(pooka/string_tree.StringTree, pooka/string_tree.StringTree) -> pooka/string_tree.StringTreeAttach another tree without walking either side.
prepend(tree: StringTree, value: String) -> StringTree
fn(pooka/string_tree.StringTree, String) -> pooka/string_tree.StringTreePlace one chunk before the earlier tree.
concat(trees: List(StringTree)) -> StringTree
fn(List(pooka/string_tree.StringTree)) -> pooka/string_tree.StringTreeJoin trees in input order without rendering their chunks.
from_strings(values: List(String)) -> StringTree
fn(List(String)) -> pooka/string_tree.StringTreeKeep each supplied chunk as a leaf.
to_string(tree: StringTree) -> String
fn(pooka/string_tree.StringTree) -> StringRender once, preserving every chunk's order.
byte_size(tree: StringTree) -> Int
fn(pooka/string_tree.StringTree) -> IntCount encoded bytes without joining the chunks.
is_empty(tree: StringTree) -> Bool
fn(pooka/string_tree.StringTree) -> BoolAsk whether rendering would produce an empty value.