pub struct CacheStorage { /* private fields */ }
Expand description
use egui::util::cache::{CacheStorage, ComputerMut, FrameCache};
#[derive(Default)]
struct CharCounter {}
impl ComputerMut<&str, usize> for CharCounter {
fn compute(&mut self, s: &str) -> usize {
s.chars().count()
}
}
type CharCountCache<'a> = FrameCache<usize, CharCounter>;
let mut cache = cache_storage.cache::<CharCountCache<'_>>();
assert_eq!(cache.get("hello"), 5);
Implementations§
Source§impl CacheStorage
impl CacheStorage
pub fn cache<FrameCache: CacheTrait + Default>(&mut self) -> &mut FrameCache
Trait Implementations§
Source§impl Clone for CacheStorage
impl Clone for CacheStorage
Source§impl Debug for CacheStorage
impl Debug for CacheStorage
Source§impl Default for CacheStorage
impl Default for CacheStorage
Source§fn default() -> CacheStorage
fn default() -> CacheStorage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CacheStorage
impl !RefUnwindSafe for CacheStorage
impl Send for CacheStorage
impl Sync for CacheStorage
impl Unpin for CacheStorage
impl !UnwindSafe for CacheStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more