pub trait UtfWidth {
// Required methods
fn utf_width(&self) -> usize;
fn utf_width_u16(&self) -> u16;
}Expand description
This trait UtfWidth is defined with a single
method utf_width that returns the width of
a string in Unicode code points.
The implementation for String and &str
types are provided. They calculate the
number of graphemes.
This method allows for easy calculation of
the horizontal space required to display
a text, which can be useful for layout purposes.
Required Methods§
Sourcefn utf_width(&self) -> usize
fn utf_width(&self) -> usize
Number of graphemes in the string. Used to know the necessary width to print this text.
Sourcefn utf_width_u16(&self) -> u16
fn utf_width_u16(&self) -> u16
Number of graphemes in the string as a, u16. Used to know the necessary width to print this text.