Struct slice_utils::FromFn

source ·
pub struct FromFn<F> {
    pub f: F,
    /* private fields */
}
Expand description

A slice calling a closure on index; see from_fn.

Fields§

§f: F

The inner closure of the slice.

Implementations§

source§

impl<F, T> FromFn<F>
where F: Fn(usize) -> Option<T>,

source

pub fn new(f: F, len: Option<usize>) -> Self

Create a slice from a closure; see from_fn.

Trait Implementations§

source§

impl<F: Clone> Clone for FromFn<F>

source§

fn clone(&self) -> FromFn<F>

Returns a copy 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<F, T> Debug for FromFn<F>
where F: Fn(usize) -> Option<T>, T: Debug,

source§

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

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

impl<F: Hash> Hash for FromFn<F>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, O, F, U> PartialEq<O> for FromFn<F>
where O: Slice<Output = U>, F: Fn(usize) -> Option<T>, U: PartialEq<T>,

source§

fn eq(&self, other: &O) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F, T> Slice for FromFn<F>
where F: Fn(usize) -> Option<T>,

§

type Output = T

The type this slice returns; analagous to Index::Output.
source§

fn len(&self) -> usize

Returns the length of the slice.
source§

fn get_with<W: FnMut(&Self::Output) -> R, R>( &self, index: usize, f: &mut W ) -> Option<R>

Call a closure with the indicated element, returning the result or None if the index was out-of-bounds. Read more
source§

fn is_empty(&self) -> bool

Returns whether or not the slice is empty. Read more
source§

fn chain<S: Slice<Output = Self::Output>>(self, other: S) -> Chain<Self, S>
where Self: Sized,

Chains two slices together, back-to-back. Read more
source§

fn cycle(self) -> Cycle<Self>
where Self: Sized,

Cycles the slice infinitely. Read more
source§

fn interleave<S: Slice<Output = Self::Output>>( self, other: S ) -> Interleave<Self, S>
where Self: Sized,

Interleaves two slices, e.g. [A, B, A, B, …]. Read more
source§

fn rev(self) -> Reverse<Self>
where Self: Sized,

Reverses the slice. Read more
source§

fn slice<R: RangeBounds<usize>>(self, range: R) -> Option<SliceOf<Self>>
where Self: Sized,

Create a sub-slice of the slice. Read more
source§

fn split(&self, at: usize) -> Option<(SliceOf<&Self>, SliceOf<&Self>)>

Returns (&self[..at], &self[at..]). Returns None if at is out-of-bounds. Read more
source§

impl<F, T> SliceOwned for FromFn<F>
where F: Fn(usize) -> Option<T>,

source§

fn get_owned(&self, index: usize) -> Option<Self::Output>

Index the slice, returning an owned value.
source§

fn array_chunks<const N: usize>(self) -> ArrayChunksOwned<Self, N>
where Self: Sized,

Return an iterator over arrays covering consecutive portions of the slice. Read more
source§

fn array_windows<const N: usize>(self) -> ArrayWindowsOwned<Self, N>
where Self: Sized,

Return a slice/iterator over arrays covering overlapping portions of the slice. Read more
source§

fn chunks(&self, size: usize) -> ChunksOwned<'_, Self>

Return an iterator over slices covering consecutive portions of the slice. Read more
source§

fn map<F: Fn(Self::Output) -> R, R>(self, f: F) -> MapOwned<Self, F>
where Self: Sized,

Call a closure on index, returning a new type. Read more
source§

fn iter(self) -> IterOwned<Self>
where Self: Sized,

Creates an iterator over the slice. Read more
source§

fn try_array<const N: usize>(&self) -> Option<[Self::Output; N]>

Try to collect the slice into an array, failing if the lengths don’t match up. Read more
source§

fn windows(&self, size: usize) -> WindowsOwned<'_, Self>

Return a slice/iterator over slices covering overlapping portions of the slice. Read more
source§

fn zip<O: SliceOwned>(self, other: O) -> Zip<Self, O>
where Self: Sized,

Zip two slices into a single slice, where indexing returns a tuple of their items. Read more
source§

impl<F: Copy> Copy for FromFn<F>

Auto Trait Implementations§

§

impl<F> Freeze for FromFn<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for FromFn<F>
where F: RefUnwindSafe,

§

impl<F> Send for FromFn<F>
where F: Send,

§

impl<F> Sync for FromFn<F>
where F: Sync,

§

impl<F> Unpin for FromFn<F>
where F: Unpin,

§

impl<F> UnwindSafe for FromFn<F>
where 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> 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>,

§

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>,

§

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.