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
caculation: T
value: HashMap<P, O>
Methods
impl<T, P, O> Cacher<T, P, O> where
T: Fn(P) -> O,
P: Eq + Hash + Copy,
O: Copy,
[src]
impl<T, P, O> Cacher<T, P, O> where
T: Fn(P) -> O,
P: Eq + Hash + Copy,
O: Copy,
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);