pub struct Cell {
pub width: u8,
pub style: StyleId,
/* private fields */
}Expand description
One cell: a grapheme and its style. A wide grapheme’s second column is a continuation cell (empty text, width 0).
A cell is small and Copy, with no heap string: a grapheme of up to
four bytes (every single character, and short clusters such as e and
a combining accent) is kept inline, and a longer one (an emoji joined
with ZWJs) as an index into a table of every such grapheme seen, which
is shared by all screens and only grows. Comparing, copying and
scrolling cells moves plain data, as a game keeps its hot data flat.
use rich_ext::frame::StyleId;
use rich_ext::surface::Cell;
let a = Cell::new("é", 1, StyleId::NONE);
let family = Cell::new("👨\u{200d}👩\u{200d}👧", 2, StyleId::NONE);
assert_eq!((a.text(), family.text()), ("é", "👨\u{200d}👩\u{200d}👧"));
assert_eq!(family, Cell::new("👨\u{200d}👩\u{200d}👧", 2, StyleId::NONE));
assert_eq!(std::mem::size_of::<Cell>(), 12);Fields§
§width: u8§style: StyleIdImplementations§
Trait Implementations§
impl Copy for Cell
impl Eq for Cell
impl StructuralPartialEq for Cell
Auto Trait Implementations§
impl Freeze for Cell
impl RefUnwindSafe for Cell
impl Send for Cell
impl Sync for Cell
impl Unpin for Cell
impl UnsafeUnpin for Cell
impl UnwindSafe for Cell
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.