Struct testclourse::Cacher[][src]

pub struct Cacher<T, P, O> where
    T: Fn(P) -> O,
    P: Eq + Hash + Copy,
    O: Copy
{ pub caculation: T, pub value: HashMap<P, O>, }

Fields

Methods

impl<T, P, O> Cacher<T, P, O> where
    T: Fn(P) -> O,
    P: Eq + Hash + Copy,
    O: Copy
[src]

let mut c = testclourse::Cacher::new(|a| a);
let v = c.value(2);
assert_eq!(v, 2);
let mut c2 = testclourse::Cacher::new(|mystring: &str| mystring.len());
let v2 = c2.value("abcd");
assert_eq!(v, 2);

Auto Trait Implementations

impl<T, P, O> Send for Cacher<T, P, O> where
    O: Send,
    P: Send,
    T: Send

impl<T, P, O> Sync for Cacher<T, P, O> where
    O: Sync,
    P: Sync,
    T: Sync