pub struct UnicodeUtils;Implementations§
Source§impl UnicodeUtils
impl UnicodeUtils
Sourcepub fn char_width(c: char) -> usize
pub fn char_width(c: char) -> usize
Returns visual width of a single character. CJK and full-width = 2, combining/zero-width = 0, else 1.
pub fn display_width(s: &str) -> usize
pub fn truncate_display(s: &str, max_width: usize) -> &str
pub fn pad_display(s: &str, width: usize, align: Align) -> String
Sourcepub fn normalize_nfc(s: &str) -> String
pub fn normalize_nfc(s: &str) -> String
Simplified NFC normalization — decomposes and recomposes common diacritics. Full NFC would require Unicode normalization tables; this handles common cases.
pub fn to_title_case(s: &str) -> String
pub fn to_snake_case(s: &str) -> String
pub fn to_camel_case(s: &str) -> String
Sourcepub fn word_wrap(text: &str, max_width: usize) -> Vec<String>
pub fn word_wrap(text: &str, max_width: usize) -> Vec<String>
Word-wrap text to max_width, respecting CJK double-width characters.
pub fn repeat_char(ch: char, n: usize) -> String
pub fn center_in_width(s: &str, width: usize) -> String
pub fn strip_ansi(s: &str) -> String
Auto Trait Implementations§
impl Freeze for UnicodeUtils
impl RefUnwindSafe for UnicodeUtils
impl Send for UnicodeUtils
impl Sync for UnicodeUtils
impl Unpin for UnicodeUtils
impl UnsafeUnpin for UnicodeUtils
impl UnwindSafe for UnicodeUtils
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.