pub struct SizeCache<T = ()> {
pub value: usize,
pub constrained: bool,
pub extra: T,
}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: usizeCached value
constrained: booltrue if the last size was constrained.
If unconstrained, any request larger than this value would return the same size.
extra: TExtra field.
Implementations§
Source§impl 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:
sizemust fit insidereq.- for each dimension,
constrained = (size == req)
Source§impl<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§
impl<T> Copy for SizeCache<T>where
T: Copy,
impl<T> Eq for SizeCache<T>where
T: Eq,
impl<T> StructuralPartialEq for SizeCache<T>
Auto Trait Implementations§
impl<T> Freeze for SizeCache<T>where
T: Freeze,
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§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.