pub trait Cache {
type Arg;
type Output;
// Required methods
fn new() -> Self;
fn get(&self, arg: &Self::Arg) -> Option<&Self::Output>;
fn cache(&mut self, arg: Self::Arg, result: Self::Output);
fn clear(&mut self);
}
Expand description
The cache for single-thread memoization.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<Arg: Clone + Eq + Hash, Output: Clone> Cache for HashMap<Arg, Output>
Use HashMap
as Cache
.
impl<Arg: Clone + Eq + Hash, Output: Clone> Cache for HashMap<Arg, Output>
Use HashMap
as Cache
.