pub struct KeyBuilder { /* private fields */ }
Expand description
Builder to create keys based on several other keys. For instance, we have a structure:
struct MyStruct(u8, String, u32, Box<f64>);
and we want to store this structure inside Art tree. This structure can identified
by first 2 fields: (u8, String)
. We can create compound key based on them and use it as
tree key.
use art_tree::Art;
use art_tree::KeyBuilder;
use art_tree::ByteString;
struct MyStruct(u8, String, u32, Box<f64>);
let mut art = Art::new();
let key = KeyBuilder::new().append(1).append(ByteString::new("abc".to_string().as_bytes())).build();
let val = MyStruct(1, "abc".to_string(), 200, Box::new(0.1));
assert!(art.insert(key.clone(), val));
assert!(art.get(&key).is_some());
Implementations§
Source§impl KeyBuilder
impl KeyBuilder
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyBuilder
impl RefUnwindSafe for KeyBuilder
impl Send for KeyBuilder
impl Sync for KeyBuilder
impl Unpin for KeyBuilder
impl UnwindSafe for KeyBuilder
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