Skip to main content

MemoizedSubView

Struct MemoizedSubView 

Source
pub struct MemoizedSubView<'a> { /* private fields */ }
Expand description

A SubView that remembers what each proposal measured.

Containers probe the same child repeatedly — size_that_fits measures at the ideal proposal, place measures again at the resolved bounds, alignment-guide resolution measures once more per guide — and a container that is itself a child re-runs all of that for its own parent’s probes, so the repeats multiply with tree depth. Wrapping each child for the duration of one pass collapses them to one measure per distinct proposal.

The cache is a fixed-capacity inline array, scanned linearly: a pass probes any one child a handful of times, and keeping it inline means wrapping a child costs no allocation — which matters on the embedded backend, whose budget is heap traffic per frame rather than CPU. A child probed at more than MEMOIZED_PROPOSALS distinct proposals simply measures again for the extras. Entries are keyed on the proposal’s bits, so -0.0 and a NaN proposal compare consistently instead of by float equality.

Implementations§

Source§

impl<'a> MemoizedSubView<'a>

Source

pub fn new(inner: &'a dyn SubView) -> MemoizedSubView<'a>

Wraps inner with a cache that lives as long as this value.

Trait Implementations§

Source§

impl Debug for MemoizedSubView<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl SubView for MemoizedSubView<'_>

Source§

fn measure(&self, proposal: ProposalSize) -> ViewDimensions

Measure the child for a given proposal. Read more
Source§

fn stretch_axis(&self) -> StretchAxis

Which axis (or axes) this view stretches to fill available space. Read more
Source§

fn priority(&self) -> i32

Layout priority for space distribution. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for MemoizedSubView<'a>

§

impl<'a> !RefUnwindSafe for MemoizedSubView<'a>

§

impl<'a> !Send for MemoizedSubView<'a>

§

impl<'a> !Sync for MemoizedSubView<'a>

§

impl<'a> !UnwindSafe for MemoizedSubView<'a>

§

impl<'a> Unpin for MemoizedSubView<'a>

§

impl<'a> UnsafeUnpin for MemoizedSubView<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.