Map

Struct Map 

Source
pub struct Map<C, F> { /* private fields */ }
Expand description

A view collection that transforms views from a source collection using a mapping function.

Map wraps an existing view collection and applies a transformation function to each view when it is accessed, allowing for lazy transformation of views.

Implementations§

Source§

impl<C, F, V> Map<C, F>
where C: Views, F: Fn(C::View) -> V, V: View,

Source

pub const fn new(source: C, f: F) -> Self

Creates a new Map that transforms views from the source collection.

§Parameters
  • source - The source view collection to map over
  • f - The transformation function to apply to each view
§Returns

A new Map instance that will apply the transformation to views

Trait Implementations§

Source§

impl<C: Clone, F: Clone> Clone for Map<C, F>

Source§

fn clone(&self) -> Map<C, F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<C: Debug, F: Debug> Debug for Map<C, F>

Source§

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

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

impl<C, F, V> Views for Map<C, F>
where C: Views, F: Clone + Fn(C::View) -> V, V: View,

Source§

type Id = <C as Views>::Id

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

type Guard = <C as Views>::Guard

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 len(&self) -> usize

Returns the number of items in the collection.
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 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<C, F> Freeze for Map<C, F>
where C: Freeze, F: Freeze,

§

impl<C, F> RefUnwindSafe for Map<C, F>

§

impl<C, F> Send for Map<C, F>
where C: Send, F: Send,

§

impl<C, F> Sync for Map<C, F>
where C: Sync, F: Sync,

§

impl<C, F> Unpin for Map<C, F>
where C: Unpin, F: Unpin,

§

impl<C, F> UnwindSafe for Map<C, F>
where C: UnwindSafe, F: UnwindSafe,

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> 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> 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 = 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.