HasWidth

Trait HasWidth 

Source
pub trait HasWidth {
    // Required method
    fn width(&self) -> Width;
}
Expand description

Support for returning the unicode width of a text object

Required Methods§

Source

fn width(&self) -> Width

Return the unicode width of an object

§Example
use stylish_stringlike::text::{HasWidth, Width};
let foo = "foobar";
assert_eq!(foo.width(), Width::Bounded(6));
let bar = String::from("🙈🙉🙊");
assert_eq!(bar.width(), Width::Bounded(6));

Implementations on Foreign Types§

Source§

impl HasWidth for &str

Source§

fn width(&self) -> Width

Source§

impl HasWidth for String

Source§

fn width(&self) -> Width

Source§

impl<T> HasWidth for Option<T>
where T: HasWidth,

Source§

fn width(&self) -> Width

Implementors§

Source§

impl<'a, T> HasWidth for Repeat<'a, T>

Source§

impl<'a, T, U: Clone> HasWidth for TextWidget<'a, T, U>
where T: HasWidth + Clone,

Source§

impl<'a, T: Clone> HasWidth for Span<'a, T>

Source§

impl<T> HasWidth for Spans<T>