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
impl LazyItems
Sourcepub fn key(self, key: impl Fn(usize) -> u64 + 'static) -> LazyItems
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.
Sourcepub fn content_type(
self,
content_type: impl Fn(usize) -> u64 + 'static,
) -> LazyItems
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LazyItems
impl !Send for LazyItems
impl !Sync for LazyItems
impl !UnwindSafe for LazyItems
impl Freeze for LazyItems
impl Unpin for LazyItems
impl UnsafeUnpin for LazyItems
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