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.
Implementations
sourceimpl SizeCache
impl SizeCache
sourcepub fn accept(self, request: usize) -> bool
pub fn accept(self, request: usize) -> bool
Returns true
if self
is still valid for the given request
.
sourcepub fn build(size: Vec2, req: Vec2) -> XY<Self>
pub fn build(size: Vec2, req: Vec2) -> XY<Self>
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)
Trait Implementations
impl Copy for SizeCache
impl StructuralPartialEq for SizeCache
Auto Trait Implementations
impl RefUnwindSafe for SizeCache
impl Send for SizeCache
impl Sync for SizeCache
impl Unpin for SizeCache
impl UnwindSafe for SizeCache
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