pub struct KeyList { /* private fields */ }Expand description
Stores key records (u64) forming the Trie structure. Index 0 is reserved as null.
Implementations§
Source§impl KeyList
impl KeyList
pub fn new() -> Self
Sourcepub fn push(&mut self, record: u64) -> u16
pub fn push(&mut self, record: u64) -> u16
Appends a key record and returns its index.
§Examples
use state_engine::common::pool::KeyList;
let mut list = KeyList::new();
let idx = list.push(0xDEAD_BEEF_u64);
assert_ne!(idx, 0);
assert_eq!(list.get(idx), Some(0xDEAD_BEEF_u64));
assert_eq!(list.get(0), Some(0u64)); // null slot
assert_eq!(list.get(999), None);
// set overwrites in place
list.set(idx, 0xCAFE);
assert_eq!(list.get(idx), Some(0xCAFE));Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyList
impl RefUnwindSafe for KeyList
impl Send for KeyList
impl Sync for KeyList
impl Unpin for KeyList
impl UnsafeUnpin for KeyList
impl UnwindSafe for KeyList
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