Trie

Struct Trie 

Source
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>

Source

pub fn load_from_file(path: &str) -> Result<Self, BincodeError>
where for<'de> V: Serialize + Deserialize<'de>,

Returns a Trie from a file - can be empty or a previously saved trie. The type of V (the Trie values) must be known

Source

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.

Source

pub fn get(&self, key: &str) -> Option<&V>

Get an entry from the Trie. Traverses the trie with the chars in the key.

Source

pub fn get_mut(&mut self, key: &str) -> Option<&mut V>

Get a mutable reference to the Trie entry. Use this to modify entries.

Source

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<V: Debug> Debug for Trie<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Default> Default for Trie<V>

Source§

fn default() -> Trie<V>

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V: PartialEq> PartialEq for Trie<V>

Source§

fn eq(&self, other: &Trie<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V> Serialize for Trie<V>
where V: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,