Skip to main content

UnicodeWidthStr

Trait UnicodeWidthStr 

Source
pub trait UnicodeWidthStr: Sealed {
    // Required methods
    fn width(&self) -> usize;
    fn width_cjk(&self) -> usize;
}
Expand description

Methods for determining displayed width of Unicode strings.

Required Methods§

Source

fn width(&self) -> usize

Returns the string’s displayed width in columns.

This function treats characters in the Ambiguous category according to Unicode Standard Annex #11 as 1 column wide. This is consistent with the recommendations for non-CJK contexts, or when the context cannot be reliably determined.

Source

fn width_cjk(&self) -> usize

Returns the string’s displayed width in columns.

This function treats characters in the Ambiguous category according to Unicode Standard Annex #11 as 2 column wide. This is consistent with the recommendations for CJK contexts.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl UnicodeWidthStr for str

Source§

fn width(&self) -> usize

Source§

fn width_cjk(&self) -> usize

Implementors§