UtfWidth

Trait UtfWidth 

Source
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§

Source

fn utf_width(&self) -> usize

Number of graphemes in the string. Used to know the necessary width to print this text.

Source

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.

Implementations on Foreign Types§

Source§

impl UtfWidth for &str

Source§

impl UtfWidth for String

Implementors§