Struct OptIter

Source
pub struct OptIter<'a, V: Vec1View<T>, T> {
    pub view: &'a V,
    pub item: PhantomData<T>,
}
Expand description

An iterator adapter that wraps a Vec1View and converts its items to Option types.

This struct provides a way to iterate over a Vec1View while converting each item to an Option type. It’s particularly useful when working with types that implement the IsNone trait, allowing for a uniform representation of potentially absent values.

§Type Parameters

  • 'a: The lifetime of the reference to the underlying Vec1View.
  • V: The type of the underlying Vec1View.
  • T: The item type of the Vec1View.

§Fields

  • view: A reference to the underlying Vec1View.
  • item: A PhantomData to carry the item type T.

Fields§

§view: &'a V§item: PhantomData<T>

Trait Implementations§

Source§

impl<V: Vec1View<T>, T> GetLen for OptIter<'_, V, T>

Source§

fn len(&self) -> usize

Returns the number of elements in the collection. Read more
Source§

fn is_empty(&self) -> bool

Checks if the collection is empty. Read more
Source§

impl<'a, 'b, V: Vec1View<T>, T: IsNone> IntoIterator for &'b OptIter<'a, V, T>

Source§

type Item = Option<<T as IsNone>::Inner>

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn TrustedLen<Item = Option<<T as IsNone>::Inner>> + 'b>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V: Vec1View<T>, T: IsNone> TIter<Option<<T as IsNone>::Inner>> for OptIter<'_, V, T>

Source§

fn titer(&self) -> impl TIterator<Item = Option<<T as IsNone>::Inner>>

Creates a trusted iterator over the items of this collection. Read more
Source§

fn map<'a, U, F>(&'a self, f: F) -> impl TIterator<Item = U>
where F: FnMut(T) -> U, T: 'a,

Maps each item in the collection using the provided function. Read more
Source§

impl<'a, T: IsNone + 'a, V: Vec1View<T>> Vec1View<Option<<T as IsNone>::Inner>> for OptIter<'a, V, T>
where for<'b> V::SliceOutput<'b>: TIter<T>,

Source§

type SliceOutput<'b> = Vec<Option<<T as IsNone>::Inner>> where Self: 'b

Source§

fn slice<'b>( &'b self, start: usize, end: usize, ) -> TResult<Self::SliceOutput<'b>>
where T: 'b,

Attempts to create a slice of the vector from the given start and end indices. Read more
Source§

fn get_backend_name(&self) -> &'static str

Returns the name of the backend implementation. Read more
Source§

unsafe fn uget(&self, index: usize) -> Option<T::Inner>

Get the value at the index Read more
Source§

unsafe fn uslice<'a>( &'a self, start: usize, end: usize, ) -> TResult<Self::SliceOutput<'a>>
where T: 'a,

Creates an unsafe slice of the vector from the given start and end indices. Read more
Source§

fn try_as_slice(&self) -> Option<&[T]>

Attempts to return a reference to the underlying slice of the vector. Read more
Source§

fn iter_cast<'a, U>(&'a self) -> impl TIterator<Item = U>
where T: 'a + Cast<U>,

Creates an iterator that casts each element of the vector to a new type. Read more
Source§

fn opt_iter_cast<'a, U>(&'a self) -> impl TIterator<Item = Option<U>>
where T: IsNone + 'a, <T as IsNone>::Inner: Cast<U>,

Creates an iterator that optionally casts each element of the vector to a new type. Read more
Source§

fn opt(&self) -> OptIter<'_, Self, T>
where T: IsNone, Self: Sized,

Creates an OptIter for the vector. Read more
Source§

fn to_opt_iter<'a>(&'a self) -> impl TIterator<Item = Option<T::Inner>>
where T: IsNone + 'a,

Creates an iterator that converts each element of the vector to an Option. Read more
Source§

unsafe fn uvget(&self, index: usize) -> Option<T::Inner>
where T: IsNone,

Retrieves the value at the specified index as an Option, if it’s valid. Read more
Source§

fn get(&self, index: usize) -> TResult<T>

Safely retrieves the value at the specified index. Read more
Source§

fn vget(&self, index: usize) -> Option<T::Inner>
where T: IsNone,

Safely retrieves the value at the specified index as an Option. Read more
Source§

fn rolling_custom_iter<'a, U, F>( &'a self, window: usize, f: F, ) -> impl TrustedLen<Item = U>
where F: FnMut(Self::SliceOutput<'a>) -> U, T: 'a,

Applies a custom function to rolling windows of the vector. Read more
Source§

fn rolling_custom<'a, O: Vec1<OT>, OT: Clone, F>( &'a self, window: usize, f: F, out: Option<O::UninitRefMut<'_>>, ) -> Option<O>
where F: FnMut(Self::SliceOutput<'a>) -> OT, Self: 'a, T: 'a,

Applies a custom function to rolling windows of the vector and collects the results. Read more
Source§

fn rolling_custom_to<'a, O: Vec1<OT>, OT, F>( &'a self, window: usize, f: F, out: O::UninitRefMut<'_>, )
where F: FnMut(Self::SliceOutput<'a>) -> OT, Self: 'a, T: 'a,

Applies a custom function to rolling windows of the vector and writes the results to a provided buffer. Read more
Source§

fn rolling2_custom<O: Vec1<OT>, OT: Clone, V2, T2, F>( &self, other: &V2, window: usize, f: F, out: Option<O::UninitRefMut<'_>>, ) -> Option<O>
where V2: Vec1View<T2>, F: FnMut(Self::SliceOutput<'_>, V2::SliceOutput<'_>) -> OT,

Applies a custom function to rolling windows of two vectors simultaneously. Read more
Source§

fn rolling_apply<O: Vec1<OT>, OT, F>( &self, window: usize, f: F, out: Option<O::UninitRefMut<'_>>, ) -> Option<O>
where T: Clone, F: FnMut(Option<T>, T) -> OT,

Applies a rolling function that considers both the removal and addition of elements in the window. Read more
Source§

fn rolling_apply_to<O: Vec1<OT>, OT, F>( &self, window: usize, f: F, out: O::UninitRefMut<'_>, )
where T: Clone, F: FnMut(Option<T>, T) -> OT,

Applies a rolling function that considers both the removal and addition of elements in the window, writing results to a provided buffer. Read more
Source§

fn rolling2_apply<O: Vec1<OT>, OT, V2: Vec1View<T2>, T2, F>( &self, other: &V2, window: usize, f: F, out: Option<O::UninitRefMut<'_>>, ) -> Option<O>
where T: Clone, T2: Clone, F: FnMut(Option<(T, T2)>, (T, T2)) -> OT,

Applies a rolling function to two vectors simultaneously, considering both the removal and addition of elements in the window. Read more
Source§

fn rolling2_apply_to<O: Vec1<OT>, OT, V2: Vec1View<T2>, T2, F>( &self, other: &V2, window: usize, f: F, out: O::UninitRefMut<'_>, )
where F: FnMut(Option<(T, T2)>, (T, T2)) -> OT,

Applies a rolling function to two vectors simultaneously, writing results to a provided buffer. Read more
Source§

fn rolling_apply_idx<O: Vec1<OT>, OT, F>( &self, window: usize, f: F, out: Option<O::UninitRefMut<'_>>, ) -> Option<O>
where F: FnMut(Option<usize>, usize, T) -> OT,

Applies a rolling function that considers the index of elements in the window. Read more
Source§

fn rolling_apply_idx_to<O: Vec1<OT>, OT, F>( &self, window: usize, f: F, out: O::UninitRefMut<'_>, )
where F: FnMut(Option<usize>, usize, T) -> OT,

Applies a rolling function that considers the index of elements in the window, writing results to a provided buffer. Read more
Source§

fn rolling2_apply_idx<O: Vec1<OT>, OT, V2: Vec1View<T2>, T2, F>( &self, other: &V2, window: usize, f: F, out: Option<O::UninitRefMut<'_>>, ) -> Option<O>
where F: FnMut(Option<usize>, usize, (T, T2)) -> OT,

Applies a rolling function to two vectors simultaneously, considering the index of elements in the window. Read more
Source§

fn rolling2_apply_idx_to<O: Vec1<OT>, OT, V2: Vec1View<T2>, T2, F>( &self, other: &V2, window: usize, f: F, out: O::UninitRefMut<'_>, )
where F: FnMut(Option<usize>, usize, (T, T2)) -> OT,

Applies a rolling function to two vectors simultaneously, considering the index of elements in the window, writing results to a provided buffer. Read more

Auto Trait Implementations§

§

impl<'a, V, T> Freeze for OptIter<'a, V, T>

§

impl<'a, V, T> RefUnwindSafe for OptIter<'a, V, T>

§

impl<'a, V, T> Send for OptIter<'a, V, T>
where V: Sync, T: Send,

§

impl<'a, V, T> Sync for OptIter<'a, V, T>
where V: Sync, T: Sync,

§

impl<'a, V, T> Unpin for OptIter<'a, V, T>
where T: Unpin,

§

impl<'a, V, T> UnwindSafe for OptIter<'a, V, T>

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

Source§

fn cast(self) -> T

Casts the value to the target type T. 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.