pub struct SubTrie<'a, T> { /* private fields */ }Expand description
View over the subset of a CommandTrie whose keys share a common prefix.
Construct via CommandTrie::subtrie. Guaranteed non-empty.
Implementations§
Source§impl<'a, T> SubTrie<'a, T>
impl<'a, T> SubTrie<'a, T>
Sourcepub fn common_prefix(&self) -> &str
pub fn common_prefix(&self) -> &str
Longest prefix shared by every entry in the view.
Sourcepub fn extension(&self) -> &str
pub fn extension(&self) -> &str
Bytes between the originally queried prefix and Self::common_prefix.
This is exactly what a fish-style line editor should splice into the buffer on TAB: the unambiguous auto-extension implied by what the user has typed so far. Empty when the typed prefix is already at a branch point (caller should then display the menu of completions).
Sourcepub fn is_unique(&self) -> bool
pub fn is_unique(&self) -> bool
true when exactly one entry matches — the caller can commit it and
stop prompting. O(1).
Sourcepub fn value(&self) -> Option<&'a T>
pub fn value(&self) -> Option<&'a T>
Value at this view’s deepest node, when that node itself holds a value
(i.e. Self::common_prefix is itself a stored key). Returns None
for a pure branch-point view.
Sourcepub fn unique_value(&self) -> Option<&'a T>
pub fn unique_value(&self) -> Option<&'a T>
The single matching value when this view contains exactly one entry,
else None. Combines Self::is_unique and Self::value; spares
the caller a follow-up trie.get(sub.common_prefix()).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Always false — a SubTrie only exists when at least one entry matches.