Entry

Struct Entry 

Source
pub struct Entry<K, V> { /* private fields */ }
Expand description

Trie generator.

const KEYWORDS: [(&'static str, i8); 3] = [
    ("A", 1),
    ("BB", 2),
    ("BBC", 3),
];

let tree = Entry::<char, _>::new(KEYWORDS.iter());
let tbl: Vec<Transition<_, _, _>> = tree.into();
let mut it = tbl.iter();

assert_eq!(it.next().unwrap(), &('C', 0usize, 0usize, 2usize));
assert_eq!(it.next().unwrap(), &('B', 0usize, 1usize, 1usize));
assert_eq!(it.next().unwrap(), &('A', 0usize, 0usize, 0usize));
assert_eq!(it.next().unwrap(), &('B', 1usize, 2usize, !0usize));
assert_eq!(it.next().unwrap(), &('\u{0}', 2usize, 4usize, !0usize));
assert!(it.next().is_none());

Implementations§

Source§

impl Entry<char, usize>

Source

pub fn new<'a, I, S, V>(src: I) -> Self
where I: Iterator<Item = &'a (S, V)>, S: 'a + AsRef<str>, V: 'a,

Reading const array, then creating tree structure to generate trie.

Source§

impl Entry<u8, usize>

Source

pub fn new<'a, I, S, V>(src: I) -> Self
where I: Iterator<Item = &'a (S, V)>, S: 'a + AsRef<str>, V: 'a,

Reading const array, then creating tree structure to generate trie.

Source§

impl<K, V> Entry<K, V>
where K: Copy + Ord, V: Optional,

Source

pub fn push<I>(&mut self, key: I, v: V::Inner)
where I: IntoIterator<Item = K>,

Pushing a single entry.

Source

pub fn push_to( &self, tbl: &mut Vec<Transition<K, usize, V>>, ) -> Transition<K, usize, V>

Generating trie.

Trait Implementations§

Source§

impl<K, V> Default for Entry<K, V>
where K: Default, V: Optional,

Source§

fn default() -> Self

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

impl<K, V> Into<Vec<(K, usize, usize, V)>> for Entry<K, V>
where K: Copy + Ord, V: Optional,

Source§

fn into(self) -> Vec<Transition<K, usize, V>>

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<K, V> Freeze for Entry<K, V>
where K: Freeze, V: Freeze,

§

impl<K, V> RefUnwindSafe for Entry<K, V>

§

impl<K, V> Send for Entry<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Entry<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Entry<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for Entry<K, V>
where K: UnwindSafe, 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.