pub struct Key { /* private fields */ }Expand description
Key represents a dictionary key with its string and metadata.
A key contains:
- A string (ptr + length)
- Either an ID or a weight (union)
Implementations§
Source§impl Key
impl Key
Sourcepub fn set_weight(&mut self, weight: f32)
pub fn set_weight(&mut self, weight: f32)
Sets the key weight.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the key as a byte slice.
Returns an empty slice if no string is set.
Sourcepub fn id(&self) -> usize
pub fn id(&self) -> usize
Returns the key ID.
§Safety
This accesses the union as an ID. The caller must ensure that set_id() was called more recently than set_weight().
Trait Implementations§
impl Send for Key
impl Sync for Key
Auto Trait Implementations§
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