pub struct GraphemeId(/* private fields */);Expand description
Grapheme ID: reference to an interned string in [GraphemePool].
§Layout
[30-27: width (4 bits)][26-16: generation (11 bits)][15-0: pool slot (16 bits)]§Capacity
- Pool slots: 65,536 (16 bits = 64K entries)
- Generation: 2048 versions (11 bits) for stale access detection
- Width range: 0-15 (4 bits)
§Design Rationale
- 16 bits for slot (64K) is sufficient for any single frame’s unique graphemes.
- 11 bits for generation allows detecting access to reused slots (fixing the ABA problem).
- 4 bits for width allows display widths 0-15.
- Total 31 bits leaves bit 31 for
CellContenttype discrimination.
Implementations§
Source§impl GraphemeId
impl GraphemeId
Sourcepub const MAX_GENERATION: u16 = 2047
pub const MAX_GENERATION: u16 = 2047
Maximum generation (11 bits).
Sourcepub const fn new(slot: u32, generation: u16, width: u8) -> Self
pub const fn new(slot: u32, generation: u16, width: u8) -> Self
Create a new GraphemeId from slot index, generation, and display width.
§Panics
Panics in debug mode if slot > MAX_SLOT or width > MAX_WIDTH.
Sourcepub const fn generation(self) -> u16
pub const fn generation(self) -> u16
Extract the generation counter (0-2047).
Trait Implementations§
Source§impl Clone for GraphemeId
impl Clone for GraphemeId
Source§fn clone(&self) -> GraphemeId
fn clone(&self) -> GraphemeId
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GraphemeId
impl Debug for GraphemeId
Source§impl Default for GraphemeId
impl Default for GraphemeId
Source§fn default() -> GraphemeId
fn default() -> GraphemeId
Returns the “default value” for a type. Read more
Source§impl Hash for GraphemeId
impl Hash for GraphemeId
Source§impl PartialEq for GraphemeId
impl PartialEq for GraphemeId
impl Copy for GraphemeId
impl Eq for GraphemeId
impl StructuralPartialEq for GraphemeId
Auto Trait Implementations§
impl Freeze for GraphemeId
impl RefUnwindSafe for GraphemeId
impl Send for GraphemeId
impl Sync for GraphemeId
impl Unpin for GraphemeId
impl UnsafeUnpin for GraphemeId
impl UnwindSafe for GraphemeId
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