pub struct Trie<V> { /* private fields */ }Expand description
The Trie struct. The children are a std::collections::HashMap of other Tries.
Implementations§
Source§impl<V> Trie<V>
impl<V> Trie<V>
Sourcepub fn load_from_file(path: &str) -> Result<Self, BincodeError>where
for<'de> V: Serialize + Deserialize<'de>,
pub fn load_from_file(path: &str) -> Result<Self, BincodeError>where
for<'de> V: Serialize + Deserialize<'de>,
Returns a Trie
Sourcepub fn insert(&mut self, key: &str, contents: V) -> Option<V>
pub fn insert(&mut self, key: &str, contents: V) -> Option<V>
Inserts a Trie entry. The &str key is split into its chars to generate the children.
Sourcepub fn get(&self, key: &str) -> Option<&V>
pub fn get(&self, key: &str) -> Option<&V>
Get an entry from the Trie. Traverses the trie with the chars in the key.
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut V>
pub fn get_mut(&mut self, key: &str) -> Option<&mut V>
Get a mutable reference to the Trie entry. Use this to modify entries.
Sourcepub fn save_to_file(&mut self, path: &str) -> Result<(), BincodeError>where
for<'de> V: Serialize + Deserialize<'de>,
pub fn save_to_file(&mut self, path: &str) -> Result<(), BincodeError>where
for<'de> V: Serialize + Deserialize<'de>,
Save the Trie to a file.
Trait Implementations§
Source§impl<'de, V> Deserialize<'de> for Trie<V>where
V: Deserialize<'de>,
impl<'de, V> Deserialize<'de> for Trie<V>where
V: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<V> StructuralPartialEq for Trie<V>
Auto Trait Implementations§
impl<V> Freeze for Trie<V>where
V: Freeze,
impl<V> RefUnwindSafe for Trie<V>where
V: RefUnwindSafe,
impl<V> Send for Trie<V>where
V: Send,
impl<V> Sync for Trie<V>where
V: Sync,
impl<V> Unpin for Trie<V>where
V: Unpin,
impl<V> UnwindSafe for Trie<V>where
V: UnwindSafe,
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