pub struct RangeMatcher<T> { /* private fields */ }Expand description
Numeric range matcher for finding keys within a specified range.
This matcher is useful for numeric keys like IDs, scores, timestamps, or any other ordered numeric data.
§Examples
use simple_cacher::*;
use std::time::Duration;
let mut cache = SimpleCacher::new(Duration::from_secs(300));
cache.insert(85, "Good score".to_string());
cache.insert(92, "Excellent score".to_string());
cache.insert(67, "Average score".to_string());
cache.insert(45, "Poor score".to_string());
let high_score_matcher = RangeMatcher::new(80, 100);
let high_scores = cache.get_all_by_matcher(&high_score_matcher);
assert_eq!(high_scores.len(), 2); // 85 and 92Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for RangeMatcher<T>where
T: Freeze,
impl<T> RefUnwindSafe for RangeMatcher<T>where
T: RefUnwindSafe,
impl<T> Send for RangeMatcher<T>where
T: Send,
impl<T> Sync for RangeMatcher<T>where
T: Sync,
impl<T> Unpin for RangeMatcher<T>where
T: Unpin,
impl<T> UnwindSafe for RangeMatcher<T>where
T: 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