AnyViews

Struct AnyViews 

Source
pub struct AnyViews<V>(/* private fields */);
Expand description

A type-erased container for Views collections.

AnyViews provides a uniform interface to different views collections by wrapping them in a type-erased container. This enables working with heterogeneous view collections through a common interface.

Implementations§

Source§

impl<V> AnyViews<V>
where V: View,

Source

pub fn new<C>(contents: C) -> Self
where C: Views<View = V> + 'static,

Creates a new type-erased view collection from any type implementing the Views trait.

This function wraps the provided collection in a type-erased container, allowing different view collection implementations to be used through a common interface.

§Parameters
  • contents - Any collection implementing the Views trait with the appropriate item type
§Returns

A new AnyViews instance containing the provided collection

Trait Implementations§

Source§

impl<V> Debug for AnyViews<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V> From<AnyViews<V>> for SharedAnyViews<V>

Source§

fn from(value: AnyViews<V>) -> Self

Converts to this type from the input type.
Source§

impl<V> Views for AnyViews<V>
where V: View,

Source§

type Id = SelfId<Id>

The type of unique identifier for items in the collection. Must implement Hash and Ord to ensure uniqueness and ordering.
Source§

type Guard = Box<dyn WatcherGuard>

The type of guard returned when registering a watcher.
Source§

type View = V

The view type that this collection produces for each element.
Source§

fn get_id(&self, index: usize) -> Option<Self::Id>

Returns the unique identifier for the item at the specified index, or None if out of bounds.
Source§

fn get_view(&self, index: usize) -> Option<Self::View>

Returns the view at the specified index, or None if the index is out of bounds.
Source§

fn len(&self) -> usize

Returns the number of items in the collection.
Source§

fn watch( &self, range: impl RangeBounds<usize>, watcher: impl for<'a> Fn(Context<&'a [Self::Id]>) + 'static, ) -> Self::Guard

Registers a watcher for changes in the specified range of the collection. Read more
Source§

fn is_empty(&self) -> bool

Returns true if the collection contains no elements.

Auto Trait Implementations§

§

impl<V> Freeze for AnyViews<V>

§

impl<V> !RefUnwindSafe for AnyViews<V>

§

impl<V> !Send for AnyViews<V>

§

impl<V> !Sync for AnyViews<V>

§

impl<V> Unpin for AnyViews<V>

§

impl<V> !UnwindSafe for AnyViews<V>

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> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
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.
Source§

impl<T> ViewsExt for T
where T: Views,

Source§

fn map<F, V>(self, f: F) -> Map<Self, F>
where Self: Sized, F: Fn(Self::View) -> V, V: View,

Transforms each view in the collection using the provided mapping function. Read more
Source§

fn erase(self) -> AnyViews<AnyView>
where Self: 'static + Sized,

Erases the specific type of the view collection, returning a type-erased AnyViews.