Skip to main content

Module string

Module string 

Source
Expand description

Lean’s String: UTF-8 text, addressed by byte position.

Positions are Nat byte offsets. A position is valid when it is at most the length in bytes and falls on a character boundary; the functions without fast in their name accept any position and behave as Lean’s definitions say for invalid ones. As in lean.h, arguments are borrowed unless noted and results are owned.

Functions§

from_string
A new string object that takes over the buffer of text.
held_string⚠
The String a string object holds, for lending it as it is.
into_string⚠
The text of a string object, giving up one reference to it. Takes the buffer without copying when nothing else refers to the object.
mk_string
A new string object.
string_append⚠
Consumes s1.
string_compare⚠
An Ordering: 0 for less, 1 for equal, 2 for greater.
string_data⚠
The characters as a List Char. Consumes s.
string_dec_eq⚠
string_dec_lt⚠
string_get_byte_fast⚠
string_hash⚠
string_length⚠
The number of characters.
string_memcmp⚠
Whether len bytes of the two strings, from the given byte offsets, are equal.
string_mk⚠
A string from a List Char, which it consumes.
string_of_usize
string_push⚠
Consumes s.
string_pushn⚠
Appends n copies of a character. Consumes s.
string_uget_byte_fast⚠
string_utf8_at_end⚠
string_utf8_byte_size⚠
string_utf8_extract⚠
The text from begin to end. Empty unless begin is a valid position before end; runs to the end of the string unless end is a valid position.
string_utf8_extract_fast⚠
The text between two valid positions.
string_utf8_get⚠
string_utf8_get_fast⚠
For a valid position that is not the end.
string_utf8_next⚠
The position after the character at i; one byte further if there is no character.
string_utf8_next_fast⚠
string_utf8_prev⚠
The position of the character before i.
string_utf8_set⚠
Replaces the character at i. Consumes s.
text⚠
The text of a string object.