Struct ElementList

Source
pub struct ElementList<Key, Value> { /* private fields */ }
Expand description

A filterable, ordered element list.

This owns the data to create child elements, and will manage adding/removing them from the DOM as the filter requires.

The list is ordered by Key.

Implementations§

Source§

impl<Key, Value> ElementList<Key, Value>
where Key: 'static + Clone + Ord + Eq, Value: 'static,

Source

pub fn new<GenerateChild, ChildElem, ParentElem>( root: ParentElem, generate_child: GenerateChild, initial: impl Iterator<Item = (Key, Value)>, ) -> Self
where ChildElem: Into<Element>, ParentElem: Into<ElementBuilder>, GenerateChild: 'static + Fn(&Value) -> ChildElem,

Create a new ElementList.

§Panic

Panics if root has already had children added to it.

Source

pub fn is_empty(&self) -> bool

true iff the list, without a filter applied, is empty.

Source

pub fn len(&self) -> usize

The length of the list without any filter applied.

Source

pub fn insert(&mut self, key: Key, item: Value)

Insert an item into the list. If an item exists at key, it is replaced.

Source

pub fn pop(&mut self)

Pop the last element from the list. If the list is empty, this has no effect.

Source

pub fn remove(&mut self, key: &Key)

Remove the item corresponding to key. If the item is not in the list, this has no effect.

Source

pub fn filter(&mut self, f: impl 'static + Fn(&Value) -> ReadSignal<bool>)

Apply a filter to the list, replacing any existing filter.

Source

pub fn retain(&mut self, f: impl Fn(&Value) -> bool)

Remove all items for which f returns false. Matching items that are currently filtered out will still be removed.

Source

pub fn values(&mut self) -> impl Iterator<Item = Ref<'_, Value>>

An iterator over all values in the list, including hidden items. If Value is interiorly mutable and reactivity with the filter is correctly set up, it’s safe to mutate the items.

Source

pub fn clear(&mut self)

Clear all the items from the list, including filtered items.

Trait Implementations§

Source§

impl<Key, T> DomElement for ElementList<Key, T>

Auto Trait Implementations§

§

impl<Key, Value> Freeze for ElementList<Key, Value>

§

impl<Key, Value> !RefUnwindSafe for ElementList<Key, Value>

§

impl<Key, Value> !Send for ElementList<Key, Value>

§

impl<Key, Value> !Sync for ElementList<Key, Value>

§

impl<Key, Value> Unpin for ElementList<Key, Value>

§

impl<Key, Value> !UnwindSafe for ElementList<Key, Value>

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.