Expand description
Cache around a one-dimensional layout result.
This is not a View, but something to help you if you create your own Views.
Fields
value: usize
Cached value
constrained: bool
true
if the last size was constrained.
If unconstrained, any request larger than this value would return the same size.
extra: T
Extra field.
Implementations
sourceimpl SizeCache<()>
impl SizeCache<()>
sourcepub fn build(size: XY<usize>, req: XY<usize>) -> XY<SizeCache<()>>
pub fn build(size: XY<usize>, req: XY<usize>) -> XY<SizeCache<()>>
Creates a new bi-dimensional cache.
It will stay valid for the same request, and compatible ones.
A compatible request is one where, for each axis, either:
- the request is equal to the cached size, or
- the request is larger than the cached size and the cache is unconstrained
Notes:
size
must fit insidereq
.- for each dimension,
constrained = (size == req)
sourceimpl<T> SizeCache<T>
impl<T> SizeCache<T>
sourcepub fn new_extra(value: usize, constrained: bool, extra: T) -> SizeCache<T>
pub fn new_extra(value: usize, constrained: bool, extra: T) -> SizeCache<T>
Creates a new sized cache
sourcepub fn build_extra(
size: XY<usize>,
req: XY<usize>,
extra: XY<T>
) -> XY<SizeCache<T>>
pub fn build_extra(
size: XY<usize>,
req: XY<usize>,
extra: XY<T>
) -> XY<SizeCache<T>>
Creates a new bi-dimensional cache.
Similar to build()
, but includes the extra field.
Trait Implementations
sourceimpl<T> PartialEq<SizeCache<T>> for SizeCache<T>where
T: PartialEq<T>,
impl<T> PartialEq<SizeCache<T>> for SizeCache<T>where
T: PartialEq<T>,
impl<T> Copy for SizeCache<T>where
T: Copy,
impl<T> Eq for SizeCache<T>where
T: Eq,
impl<T> StructuralEq for SizeCache<T>
impl<T> StructuralPartialEq for SizeCache<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for SizeCache<T>where
T: RefUnwindSafe,
impl<T> Send for SizeCache<T>where
T: Send,
impl<T> Sync for SizeCache<T>where
T: Sync,
impl<T> Unpin for SizeCache<T>where
T: Unpin,
impl<T> UnwindSafe for SizeCache<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more