pub struct Text { /* private fields */ }Expand description
A finite sequence of Unicode code points, stored as UTF-8.
Length, indexing and slicing count code points. Nothing is normalized:
a Text is exactly the code points that built it, and equality and order
compare code points. UTF-8 preserves code-point order under byte
comparison, so the derived order over the stored bytes is data.md’s
lexicographic order by code point, with a proper prefix first.
The code-point count is taken once, when the text is built. Text whose every code point is ASCII is indexed in constant time; other text finds a position by walking it, in time linear in the position.
Implementations§
Source§impl Text
impl Text
Sourcepub fn slice(&self, start: &Int, end: &Int) -> Option<Text>
pub fn slice(&self, start: &Int, end: &Int) -> Option<Text>
Returns the code points from start up to, not including, end, or
None when 0 ≤ start ≤ end ≤ length does not hold.
Sourcepub fn code_points(&self) -> Vec<Text>
pub fn code_points(&self) -> Vec<Text>
Returns each code point as a one-code-point text, in order.
Sourcepub fn graphemes(&self) -> Vec<Text>
pub fn graphemes(&self) -> Vec<Text>
Returns each extended grapheme cluster, in order (text.graphemes).
Sourcepub fn normalize(&self) -> Text
pub fn normalize(&self) -> Text
Returns the text in Unicode normalization form C (text.normalize).
Sourcepub fn lowercase(&self) -> Text
pub fn lowercase(&self) -> Text
Returns the text under Unicode’s default, locale-independent full
lowercase mapping, with its one conditional rule, Final_Sigma: a
capital sigma that ends a word lowercases to the final form
(text.lowercase).