[][src]Struct binjs::generic::mru::MRU

pub struct MRU<T> where
    T: Eq + Clone
{ /* fields omitted */ }

A structure used to access values with repeated patterns.

use binjs_shared::mru::{ MRU, Seen };

let mut mru = MRU::new();

assert_eq!(mru.access(&'a'), Seen::Never(0), "Introducing a");
assert_eq!(mru.access(&'a'), Seen::Age(0),   "Just introduced a");
assert_eq!(mru.access(&'a'), Seen::Age(0),   "Just accessed a");
assert_eq!(mru.access(&'b'), Seen::Never(1), "Introducing b");
assert_eq!(mru.access(&'b'), Seen::Age(0),   "Just introduced b");
assert_eq!(mru.access(&'a'), Seen::Age(1),   "Accessing previous a");
assert_eq!(mru.access(&'a'), Seen::Age(0),   "Just accessed a again");
assert_eq!(mru.access(&'c'), Seen::Never(2), "Just introduced c");
assert_eq!(mru.access(&'a'), Seen::Age(1),   "Accessing previous a, again");
assert_eq!(mru.access(&'a'), Seen::Age(0),   "Accessing previous a, again");
assert_eq!(mru.access(&'b'), Seen::Age(2),   "Accessing previous b");

Methods

impl<T> MRU<T> where
    T: Eq + Clone
[src]

pub fn new() -> MRU<T>[src]

pub fn access(&mut self, value: &T) -> Seen[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for MRU<T> where
    T: RefUnwindSafe

impl<T> Send for MRU<T> where
    T: Send

impl<T> Sync for MRU<T> where
    T: Sync

impl<T> Unpin for MRU<T>

impl<T> UnwindSafe for MRU<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]