Skip to main content

ItemBatcher

Struct ItemBatcher 

Source
struct ItemBatcher {
    axis: AbstractAxis,
    index_offset: usize,
    current_span: u16,
    current_is_flex: bool,
}
Expand description

Takes an axis, and a list of grid items sorted firstly by whether they cross a flex track in the specified axis (items that don’t cross a flex track first) and then by the number of tracks they cross in specified axis (ascending order).

The list holds references so that the GridItems themselves stay in document order and only the (pointer-sized) references are sorted.

Fields§

§axis: AbstractAxis

The axis in which the ItemBatcher is operating. Used when querying properties from items.

§index_offset: usize

The starting index of the current batch

§current_span: u16

The span of the items in the current batch

§current_is_flex: bool

Whether the current batch of items cross a flexible track

Implementations§

Source§

impl ItemBatcher

Source

fn new(axis: AbstractAxis) -> Self

Create a new ItemBatcher for the specified axis

Source

fn next<'items, 'a>( &mut self, items: &'items mut [&'a mut GridItem], ) -> Option<(&'items mut [&'a mut GridItem], bool)>

This is basically a manual version of Iterator::next which passes items in as a parameter on each iteration to work around borrow checker rules

Auto Trait Implementations§

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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.