Lyricdev
GitHub

class StringBuilder

pub class StringBuilder

Builds a string a part at a time, in a buffer that doubles.

It avoids a quadratic chain of concatenations. std.string re-exports it.

Methods

pub static fn new(): StringBuilder
pub fn length(): int

Returns how many bytes it holds.

pub mut fn appendStr(s: StringView): void

Appends s, a string or a view of one.

pub mut fn appendChar(c: char): void

Appends c as its UTF-8 bytes.

pub mut fn append<T :: [Display]>(v: T): void

Appends v's text, through its showTo.

pub mut fn clear(): void

Removes every byte; the room stays.

pub fn toString(): string

Returns what it holds, as a string.