Enum text_terminal::Character
source · pub enum Character {
Single(char),
Multi(String),
}
Expand description
The character stored in each Unit
of the terminal screen.
In the typical case, a character (e.g., an ASCII letter or a single UTF-8 character)
fits into Rust’s primitive char
type, so we use that by default.
In the rare case of a character that consist of multiple UTF-8 sequences, e.g., complex emoji,
we store the entire character here as a dynamically-allocated String
.
This saves space in the typical case of a character being 4 bytes or less (char
-sized).
Variants§
Implementations§
source§impl Character
impl Character
sourcepub fn displayable_width(&self) -> u16
pub fn displayable_width(&self) -> u16
Returns the number of columns required to display this Character
within a Unit
,
either a single char
or a String
.
A return value of 0
indicates this Unit
requires special handling
to determine its displayable width.
This includes characters like new lines, carriage returns, tabs, etc.
Trait Implementations§
source§impl PartialEq<Character> for Character
impl PartialEq<Character> for Character
impl Eq for Character
impl StructuralEq for Character
impl StructuralPartialEq for Character
Auto Trait Implementations§
impl RefUnwindSafe for Character
impl Send for Character
impl Sync for Character
impl Unpin for Character
impl UnwindSafe for Character
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