Skip to main content

LazyItems

Struct LazyItems 

Source
pub struct LazyItems { /* private fields */ }
Expand description

A run of lazy items: how many, and optionally how they are identified and reused.

A count converts into this on its own, so the ordinary list reads as scope.items(20, |index| ...) — the shape Compose gets from default arguments, which Rust does not have. A list whose contents move between compositions names a key so item state follows the item rather than the slot it happened to occupy:

scope.items(LazyItems::new(rows.len()).key(|index| rows[index].id), |index| {
    Row(&rows[index]);
});

Implementations§

Source§

impl LazyItems

Source

pub fn new(count: usize) -> LazyItems

A run of count items with no key and no reuse class.

Source

pub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> LazyItems

Gives each item a stable identity, so state, animations and scroll position follow the item when the list is reordered or edited.

Source

pub fn content_type( self, content_type: impl Fn(usize) -> u64 + 'static, ) -> LazyItems

Groups items into reuse classes, so a scrolling list recycles a row into another row of the same shape rather than rebuilding it.

Source

pub fn count(&self) -> usize

How many items this run declares.

Source

pub fn key_fn(&self) -> Option<Rc<dyn Fn(usize) -> u64>>

The identity function, if the caller named one.

Source

pub fn content_type_fn(&self) -> Option<Rc<dyn Fn(usize) -> u64>>

The reuse-class function, if the caller named one.

Trait Implementations§

Source§

impl Clone for LazyItems

Source§

fn clone(&self) -> LazyItems

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for LazyItems

Source§

fn default() -> LazyItems

Returns the “default value” for a type. Read more
Source§

impl From<usize> for LazyItems

Source§

fn from(count: usize) -> LazyItems

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, <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.