pub struct ShapingCache { /* private fields */ }Expand description
LRU cache mapping CacheKey → ShapedText.
Capacity is the maximum number of entries held in memory. When capacity is exceeded the least-recently-used entry is evicted.
Implementations§
Source§impl ShapingCache
impl ShapingCache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new cache with the given maximum capacity.
A capacity of 0 is treated as effectively disabled (every lookup is a miss and nothing is stored).
Sourcepub fn get(&mut self, key: &CacheKey) -> Option<&ShapedText>
pub fn get(&mut self, key: &CacheKey) -> Option<&ShapedText>
Look up key and return a reference to the cached ShapedText if
present.
On a hit the key is promoted to the front (most-recently-used) position.
Sourcepub fn insert(&mut self, key: CacheKey, value: ShapedText)
pub fn insert(&mut self, key: CacheKey, value: ShapedText)
Insert a value for key.
If the cache is at capacity the least-recently-used entry is evicted
first. If capacity == 0 the entry is never stored.
Auto Trait Implementations§
impl Freeze for ShapingCache
impl RefUnwindSafe for ShapingCache
impl Send for ShapingCache
impl Sync for ShapingCache
impl Unpin for ShapingCache
impl UnsafeUnpin for ShapingCache
impl UnwindSafe for ShapingCache
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more