pub struct CompileCache<K, V> { /* private fields */ }Expand description
A compile cache created from one immutable key.
Compilation inputs live in the key, so changing one produces a new, empty
cache through CompileCache::map_key; nothing is ever cleared by hand.
Clones share their results. A variant distinguishes environments that are
not part of the key, such as the font snapshot a paragraph is shaped with.
Implementations§
Source§impl<K, V: Clone> CompileCache<K, V>
impl<K, V: Clone> CompileCache<K, V>
Whether two caches share their results, as clones and unchanged keys do.
Sourcepub fn is_compiled(&self) -> bool
pub fn is_compiled(&self) -> bool
Whether any result has been compiled yet.
Sourcepub fn get_or_compile(&self, variant: u64, compile: impl FnOnce(&K) -> V) -> V
pub fn get_or_compile(&self, variant: u64, compile: impl FnOnce(&K) -> V) -> V
Returns the result for a variant, compiling it once from the key. The compiler runs while the cache is locked, so concurrent callers never compile the same variant twice.
Trait Implementations§
Source§impl<K, V> Clone for CompileCache<K, V>
impl<K, V> Clone for CompileCache<K, V>
Auto Trait Implementations§
impl<K, V> Forget for CompileCache<K, V>
impl<K, V> Freeze for CompileCache<K, V>
impl<K, V> Move for CompileCache<K, V>
impl<K, V> RefUnwindSafe for CompileCache<K, V>
impl<K, V> Send for CompileCache<K, V>
impl<K, V> Sync for CompileCache<K, V>
impl<K, V> Unpin for CompileCache<K, V>
impl<K, V> UnsafeUnpin for CompileCache<K, V>
impl<K, V> UnwindSafe for CompileCache<K, V>
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