Struct Once

Source
pub struct Once<T>
where T: Clone,
{ /* private fields */ }
Expand description

An iterable which yields a wrapped value only once.

Trait Implementations§

Source§

impl<T> Iterable for Once<T>
where T: Clone,

Source§

type Item = T

Type of the item that the iterators created by the iter method yields.
Source§

type Iter = Once<T>

Type of the iterator created by the iter method.
Source§

fn iter(&self) -> Self::Iter

Creates a new iterator from this iterable yielding elements of type Iterable::Item.
Source§

fn chained<I>(self, other: I) -> Chained<Self, I>
where Self: Sized, I: Iterable<Item = Self::Item>,

Takes two iterables and creates a new iterable over both in sequence. Read more
Source§

fn cloned<'a, T>(self) -> Cloned<'a, T, Self>
where Self: Sized + Iterable<Item = &'a T>, T: Clone,

Creates an iterable, iterators of which clone all of its elements. Read more
Source§

fn copied<'a, T>(self) -> Copied<'a, T, Self>
where Self: Sized + Iterable<Item = &'a T>, T: Copy,

Creates an iterable, iterators of which copy all of its elements. Read more
Source§

fn enumerated(self) -> Enumerated<Self>
where Self: Sized,

Creates an iterable which gives the current iteration count as well as the next value. Read more
Source§

fn filter_mapped<M, U>(self, filter_map: M) -> FilterMapped<Self, M, U>
where Self: Sized, M: Fn(Self::Item) -> Option<U> + Copy,

Creates an iterable that both filters and maps. Read more
Source§

fn filtered<P>(self, filter: P) -> Filtered<Self, P>
where Self: Sized, P: Fn(&Self::Item) -> bool + Copy,

Creates an iterable which uses a closure to determine if an element should be yielded. Read more
Source§

fn flat_mapped<M, U>(self, flat_map: M) -> FlatMapped<Self, M, U>
where Self: Sized, U: IntoIterator, M: Fn(Self::Item) -> U + Copy,

Creates an iterable that works like map, but flattens nested structure. Read more
Source§

fn flattened(self) -> Flattened<Self>
where Self: Sized, Self::Item: IntoIterator,

Creates an iterable that flattens nested structure. Read more
Source§

fn fused(self) -> Fused<Self>
where Self: Sized,

Creates an iterable which ends after the first None. Read more
Source§

fn mapped_while<M, U>(self, map_while: M) -> MappedWhile<Self, M, U>
where Self: Sized, M: Fn(Self::Item) -> Option<U> + Copy,

Creates an iterable that both yields elements based on a predicate and maps. Read more
Source§

fn mapped<M, U>(self, map: M) -> Mapped<Self, M, U>
where Self: Sized, M: Fn(Self::Item) -> U + Copy,

Takes a closure and creates an iterable which calls that closure on each element. Read more
Source§

fn reversed(self) -> Reversed<Self>
where Self: Sized, Self::Iter: DoubleEndedIterator,

Creates an iterable iterators of which reverses the traversal direction. Read more
Source§

fn skipped(self, n: usize) -> Skipped<Self>
where Self: Sized,

Creates an iterable, iterators of which skip the first n elements. Read more
Source§

fn skipped_while<P>(self, skip_while: P) -> SkippedWhile<Self, P>
where Self: Sized, P: Fn(&Self::Item) -> bool + Copy,

Creates an iterable, iterators of which skip elements based on a predicate. Read more
Source§

fn stepped_by(self, step: usize) -> SteppedBy<Self>
where Self: Sized,

Creates an iterable starting at the same point, but stepping by the given amount at each iteration. Read more
Source§

fn taken(self, n: usize) -> Taken<Self>
where Self: Sized,

Creates an iterable whose iterators yield the first n elements, or fewer if the underlying iterator ends sooner. Read more
Source§

fn taken_while<P>(self, take_while: P) -> TakenWhile<Self, P>
where Self: Sized, P: Fn(&Self::Item) -> bool + Copy,

Creates an iterable, iterators of which yield elements based on a predicate. Read more
Source§

fn zipped<I>(self, other: I) -> Zipped<Self, I>
where Self: Sized, I: Iterable,

‘Zips up’ two iterables into a single iterable of pairs. Read more
Source§

impl<T> IterableObj for Once<T>
where T: Clone,

Source§

type Item = T

Type of the item that the iterators created by the boxed_iter method yields.
Source§

fn boxed_iter(&self) -> Box<dyn Iterator<Item = Self::Item> + '_>

Creates a new iterator in a box from this iterable yielding elements of type IterableObj::Item.

Auto Trait Implementations§

§

impl<T> Freeze for Once<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Once<T>
where T: RefUnwindSafe,

§

impl<T> Send for Once<T>
where T: Send,

§

impl<T> Sync for Once<T>
where T: Sync,

§

impl<T> Unpin for Once<T>
where T: Unpin,

§

impl<T> UnwindSafe for Once<T>
where T: 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> 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> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

fn get_mut(&mut self) -> &mut T

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
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.