pub struct ChainDictionary<D> { /* private fields */ }Expand description
A dictionary composition that preserves caller-supplied priority order.
Dictionaries are stored from highest to lowest priority. During lookup, matches of different byte lengths are all returned so the lattice segmenter can still compare shorter high-priority entries with longer low-priority entries. When two dictionaries produce a match with the same byte length, only the first one is kept.
Implementations§
Source§impl<D> ChainDictionary<D>
impl<D> ChainDictionary<D>
Sourcepub fn new() -> ChainDictionary<D>
pub fn new() -> ChainDictionary<D>
Creates an empty chain.
Sourcepub fn push(&mut self, dictionary: D)
pub fn push(&mut self, dictionary: D)
Appends a dictionary with lower priority than the existing entries.
Sourcepub fn dictionaries(&self) -> &[D]
pub fn dictionaries(&self) -> &[D]
Returns the chained dictionaries in priority order.
Sourcepub fn into_dictionaries(self) -> Vec<D>
pub fn into_dictionaries(self) -> Vec<D>
Consumes the chain and returns its dictionaries in priority order.
Trait Implementations§
Source§impl<D> Clone for ChainDictionary<D>where
D: Clone,
impl<D> Clone for ChainDictionary<D>where
D: Clone,
Source§fn clone(&self) -> ChainDictionary<D>
fn clone(&self) -> ChainDictionary<D>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<D> Debug for ChainDictionary<D>where
D: Debug,
impl<D> Debug for ChainDictionary<D>where
D: Debug,
Source§impl<D> Default for ChainDictionary<D>where
D: Default,
impl<D> Default for ChainDictionary<D>where
D: Default,
Source§fn default() -> ChainDictionary<D>
fn default() -> ChainDictionary<D>
Returns the “default value” for a type. Read more
impl<D> Eq for ChainDictionary<D>where
D: Eq,
Source§impl<D> FromIterator<D> for ChainDictionary<D>
impl<D> FromIterator<D> for ChainDictionary<D>
Source§fn from_iter<T>(iter: T) -> ChainDictionary<D>where
T: IntoIterator<Item = D>,
fn from_iter<T>(iter: T) -> ChainDictionary<D>where
T: IntoIterator<Item = D>,
Creates a value from an iterator. Read more
Source§impl<D> HanjaDictionary for ChainDictionary<D>where
D: HanjaDictionary,
impl<D> HanjaDictionary for ChainDictionary<D>where
D: HanjaDictionary,
Source§fn matches_at<'a>(&'a self, s: &'a str) -> Box<dyn Iterator<Item = Match> + 'a>
fn matches_at<'a>(&'a self, s: &'a str) -> Box<dyn Iterator<Item = Match> + 'a>
Yields every dictionary match that starts at the beginning of
s.Source§fn max_word_chars(&self) -> Option<usize>
fn max_word_chars(&self) -> Option<usize>
Returns the greatest dictionary entry length in Unicode scalar values.
Source§impl<D> PartialEq for ChainDictionary<D>where
D: PartialEq,
impl<D> PartialEq for ChainDictionary<D>where
D: PartialEq,
Source§fn eq(&self, other: &ChainDictionary<D>) -> bool
fn eq(&self, other: &ChainDictionary<D>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<D> StructuralPartialEq for ChainDictionary<D>
Auto Trait Implementations§
impl<D> Freeze for ChainDictionary<D>
impl<D> RefUnwindSafe for ChainDictionary<D>where
D: RefUnwindSafe,
impl<D> Send for ChainDictionary<D>where
D: Send,
impl<D> Sync for ChainDictionary<D>where
D: Sync,
impl<D> Unpin for ChainDictionary<D>where
D: Unpin,
impl<D> UnsafeUnpin for ChainDictionary<D>
impl<D> UnwindSafe for ChainDictionary<D>where
D: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.