text_fonts

module std::stringsource

The owned, growable byte string.

A String owns a heap buffer of UTF-8 bytes and a count of the bytes in use. Growth follows the manual pattern of LANGUAGE_SPEC.md section 5.2 with a doubling buffer, so appends are amortized constant. view borrows the contents in place as a plain &[u8] slice, the type every text-taking function (and string literal) already uses.

type Stringsource

exp type String : Iterable<u8, StringCursor> + Key + Equal + Format = struct

Functions

fn String::emptysource

exp fn String::empty() -> String

A string with no bytes and no allocation.

fn String::fromsource

exp fn String::from(text: &[u8]) -> String

An owned copy of the given text.

fn String::fromsource

exp fn String::from(number: i64) -> String

String representation of the given integer.

fn String::with_capacitysource

exp fn String::with_capacity(capacity: u64) -> String

Allocates a string able to hold at least capacity bytes before growing.

fn lengthsource

exp fn length(self string: &String) -> u64

The number of bytes in use.

type StringCursorsource

exp type StringCursor : Iterator<u8> = struct

The cursor behind for (string) |byte| (section 5.3): it borrows the contents once and hands out references to the bytes in place.

Functions

fn iteratorsource

exp fn iterator(self string: &String) -> StringCursor

fn nextsource

exp fn next(self cursor: &var StringCursor) -> Option<&u8>

fn viewsource

exp fn view(self string: &String) -> &[u8]

Borrows the contents in place. The view is invalidated by the next mutation (growth may reallocate), like any Alloy reference.

fn getsource

exp fn get(self string: &String, index: u64) -> &u8

The byte at the index, in place; a fault past the end.

fn pushsource

exp fn push(self string: &var String, byte: u8)

Appends one byte.

fn appendsource

exp fn append(self string: &var String, text: &[u8])

Appends every byte of the given text.

fn appendsource

exp fn append(self string: &var String, value: i64)

Appends the decimal digits of the value, written backwards into a local buffer first.

fn reservesource

exp fn reserve(self string: &var String, additional: u64)

Makes room for at least additional more bytes, so the appends up to it do not grow the buffer.

fn clearsource

exp fn clear(self string: &var String)

Empties the string; the buffer is kept for future appends.

fn truncatesource

exp fn truncate(self string: &var String, length: u64)

Keeps the first length bytes, if there are more.

fn formatsource

exp fn format(self string: &String, out: &var String)

Writes the contents as they are (std::format).

fn hashsource

exp fn hash(self string: &String) -> u64

Hashes the contents, as hash_bytes does the same text (std::hash).

fn samesource

exp fn same(self string: &String, other: &String) -> bool

True when the contents are the same, whatever the capacities.

fn equalssource

exp fn equals(self string: &String, other: &String) -> bool

What == compares: the contents, whatever the capacities.

fn equalssource

exp fn equals(self string: &String, text: &[u8]) -> bool

True when the contents equal the given text byte for byte.