Struct silkenweb::element_list::ElementList[][src]

pub struct ElementList<Key, Value> { /* fields omitted */ }

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

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

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

Create a new ElementList.

Panic

Panics if root has already had children added to it.

pub fn is_empty(&self) -> bool[src]

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

pub fn len(&self) -> usize[src]

The length of the list without any filter applied.

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

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

pub fn pop(&mut self)[src]

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

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

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

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

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

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

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

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

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.

pub fn clear(&mut self)[src]

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

Trait Implementations

impl<Key, T> DomElement for ElementList<Key, T>[src]

type Target = Element

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.