pub struct Width(/* private fields */);Expand description
A type-safe wrapper for display width values.
This type represents the visual width of text as it would appear on screen, taking into account ANSI escape sequences and Unicode character widths. It provides type safety to prevent confusion between byte lengths and display widths.
§Examples
use ansi_align::Width;
let width = Width::new(42);
assert_eq!(width.get(), 42);
// Convert from usize
let width: Width = 24.into();
assert_eq!(width.get(), 24);
// Ordering works as expected
assert!(Width::new(10) < Width::new(20));Implementations§
Trait Implementations§
Source§impl Ord for Width
impl Ord for Width
Source§impl PartialOrd for Width
impl PartialOrd for Width
impl Copy for Width
impl Eq for Width
impl StructuralPartialEq for Width
Auto Trait Implementations§
impl Freeze for Width
impl RefUnwindSafe for Width
impl Send for Width
impl Sync for Width
impl Unpin for Width
impl UnwindSafe for Width
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