pub struct HintSequence { /* private fields */ }Expand description
A hint sequence (e.g., “g”, “gg”, “ggg”)
Optimized for the common case of short sequences. Uses a base character and repetition count to represent Vimium-style hints efficiently.
§Examples
use open_sesame::core::hint::HintSequence;
// Create a hint sequence
let hint = HintSequence::new('g', 2);
assert_eq!(hint.base(), 'g');
assert_eq!(hint.count(), 2);
assert_eq!(hint.as_string(), "gg");
// Parse from string
let parsed = HintSequence::from_repeated("ggg").unwrap();
assert_eq!(parsed.count(), 3);
// Match user input
assert!(hint.matches_input("g"));
assert!(hint.matches_input("gg"));
assert!(!hint.matches_input("ggg"));Implementations§
Source§impl HintSequence
impl HintSequence
Sourcepub fn from_repeated(s: &str) -> Option<Self>
pub fn from_repeated(s: &str) -> Option<Self>
Create from a repeated letter string
Sourcepub fn matches_input(&self, input: &str) -> bool
pub fn matches_input(&self, input: &str) -> bool
Returns true if this sequence is a prefix of the given input.
Sourcepub fn equals_input(&self, input: &str) -> bool
pub fn equals_input(&self, input: &str) -> bool
Returns true if this sequence exactly equals the input.
Trait Implementations§
Source§impl Clone for HintSequence
impl Clone for HintSequence
Source§fn clone(&self) -> HintSequence
fn clone(&self) -> HintSequence
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HintSequence
impl Debug for HintSequence
Source§impl Display for HintSequence
impl Display for HintSequence
Source§impl Hash for HintSequence
impl Hash for HintSequence
Source§impl PartialEq for HintSequence
impl PartialEq for HintSequence
impl Eq for HintSequence
impl StructuralPartialEq for HintSequence
Auto Trait Implementations§
impl Freeze for HintSequence
impl RefUnwindSafe for HintSequence
impl Send for HintSequence
impl Sync for HintSequence
impl Unpin for HintSequence
impl UnwindSafe for HintSequence
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.