Struct FromFn

Source
pub struct FromFn<S: Shape, F> { /* private fields */ }
Expand description

Expression with a defined shape and elements from the given function.

Trait Implementations§

Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Add<I> for FromFn<S, F>
where T: Add<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: I) -> Self::Output

Performs the + operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> BitAnd<I> for FromFn<S, F>
where T: BitAnd<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: I) -> Self::Output

Performs the & operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> BitOr<I> for FromFn<S, F>
where T: BitOr<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: I) -> Self::Output

Performs the | operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> BitXor<I> for FromFn<S, F>
where T: BitXor<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: I) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<S: Clone + Shape, F: Clone> Clone for FromFn<S, F>
where S::Dims<usize>: Clone,

Source§

fn clone(&self) -> FromFn<S, 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<S: Shape, F> Debug for FromFn<S, F>

Source§

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

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

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Div<I> for FromFn<S, F>
where T: Div<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: I) -> Self::Output

Performs the / operation. Read more
Source§

impl<T, S: Shape, F: FnMut(&[usize]) -> T> Expression for FromFn<S, F>

Source§

const IS_REPEATABLE: bool = true

True if the expression can be restarted from the beginning after the last element.
Source§

type Shape = S

Array shape type.
Source§

fn shape(&self) -> &S

Returns the array shape.
Source§

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

Creates an expression which clones all of its elements.
Source§

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

Creates an expression which copies all of its elements.
Source§

fn dim(&self, index: usize) -> usize

Returns the number of elements in the specified dimension. Read more
Source§

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Creates an expression which gives tuples of the current count and the element.
Source§

fn eval(self) -> <Self::Shape as Shape>::Owned<Self::Item>
where Self: Sized,

Evaluates the expression into a new array. Read more
Source§

fn eval_into<S: Shape, A: Allocator>( self, tensor: &mut Tensor<Self::Item, S, A>, ) -> &mut Tensor<Self::Item, S, A>
where Self: Sized,

Evaluates the expression with broadcasting and appends to the given array along the first dimension. Read more
Source§

fn fold<T, F: FnMut(T, Self::Item) -> T>(self, init: T, f: F) -> T
where Self: Sized,

Folds all elements into an accumulator by applying an operation, and returns the result.
Source§

fn for_each<F: FnMut(Self::Item)>(self, f: F)
where Self: Sized,

Calls a closure on each element of the expression.
Source§

fn is_empty(&self) -> bool

Returns true if the array contains no elements.
Source§

fn len(&self) -> usize

Returns the number of elements in the array.
Source§

fn map<T, F: FnMut(Self::Item) -> T>(self, f: F) -> Map<Self, F>
where Self: Sized,

Creates an expression that calls a closure on each element.
Source§

fn rank(&self) -> usize

Returns the array rank, i.e. the number of dimensions.
Source§

fn zip<I: IntoExpression>(self, other: I) -> Zip<Self, I::IntoExpr>
where Self: Sized,

Creates an expression that gives tuples (x, y) of the elements from each expression. Read more
Source§

impl<T, S: Shape, F: FnMut(&[usize]) -> T> IntoIterator for FromFn<S, F>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<FromFn<S, F>>

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

fn into_iter(self) -> Iter<Self>

Creates an iterator from a value. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Mul<I> for FromFn<S, F>
where T: Mul<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: I) -> Self::Output

Performs the * operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T> Neg for FromFn<S, F>
where T: Neg<Output = U>,

Source§

type Output = <FromFn<S, F> as Apply<U>>::Output<fn(T) -> U>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T> Not for FromFn<S, F>
where T: Not<Output = U>,

Source§

type Output = <FromFn<S, F> as Apply<U>>::Output<fn(T) -> U>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Rem<I> for FromFn<S, F>
where T: Rem<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: I) -> Self::Output

Performs the % operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Shl<I> for FromFn<S, F>
where T: Shl<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: I) -> Self::Output

Performs the << operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Shr<I> for FromFn<S, F>
where T: Shr<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: I) -> Self::Output

Performs the >> operation. Read more
Source§

impl<S: Shape, T, U, F: FnMut(&[usize]) -> T, I: Apply<U>> Sub<I> for FromFn<S, F>
where T: Sub<I::Item, Output = U>,

Source§

type Output = <I as Apply<U>>::ZippedWith<FromFn<S, F>, fn((<I as IntoIterator>::Item, T)) -> U>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: I) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<S, F> Freeze for FromFn<S, F>
where S: Freeze, F: Freeze, <S as Shape>::Dims<usize>: Freeze,

§

impl<S, F> RefUnwindSafe for FromFn<S, F>

§

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

§

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

§

impl<S, F> Unpin for FromFn<S, F>
where S: Unpin, F: Unpin, <S as Shape>::Dims<usize>: Unpin,

§

impl<S, F> UnwindSafe for FromFn<S, F>
where S: UnwindSafe, F: UnwindSafe, <S as Shape>::Dims<usize>: 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, E> Apply<T> for E
where E: Expression,

Source§

type Output<F: FnMut(<E as IntoIterator>::Item) -> T> = Map<E, F>

The resulting type after applying a closure.
Source§

type ZippedWith<I: IntoExpression, F: FnMut((<E as IntoIterator>::Item, <I as IntoIterator>::Item)) -> T> = Map<Zip<E, <I as IntoExpression>::IntoExpr>, F>

The resulting type after zipping elements and applying a closure.
Source§

fn apply<F>(self, f: F) -> <E as Apply<T>>::Output<F>
where F: FnMut(<E as IntoIterator>::Item) -> T,

Returns the array or an expression with the given closure applied to each element.
Source§

fn zip_with<I, F>(self, expr: I, f: F) -> <E as Apply<T>>::ZippedWith<I, F>
where I: IntoExpression, F: FnMut((<E as IntoIterator>::Item, <I as IntoIterator>::Item)) -> T,

Returns the array or an expression with the given closure applied to zipped element pairs.
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, 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> IntoCloned<T> for T

Source§

fn clone_to(self, target: &mut T)

Moves an existing object or clones from a reference to the target object.
Source§

fn into_cloned(self) -> T

Returns an existing object or a new clone from a reference.
Source§

impl<E> IntoExpression for E
where E: Expression,

Source§

type Shape = <E as Expression>::Shape

Array shape type.
Source§

type IntoExpr = E

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

fn into_expr(self) -> E

Creates an expression from a value.
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.