Trait Cache

pub trait Cache<T: Clone> {
    // Required methods
    fn get_or_insert_with(
        &self,
        instr: &Instruction,
        new: impl FnOnce(&Instruction) -> T,
    ) -> T;
    fn num_entries(&self) -> usize;
}
Expand description

Generic trait for a cache.

Required Methods§

fn get_or_insert_with( &self, instr: &Instruction, new: impl FnOnce(&Instruction) -> T, ) -> T

fn num_entries(&self) -> usize

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.

Implementors§

§

impl<T: Clone> Cache<T> for HashMapCache<T>

§

impl<T: Clone> Cache<T> for NoCache