pub trait Stack {
type Remaining: Stack;
type Head;
// Required methods
fn pop(self) -> (Self::Remaining, Self::Head);
fn push<H>(self, head: H) -> Cons<Self, H>
where Self: Sized;
fn map<F: FnOnce(&Self::Head) -> O, O>(&self, f: F) -> O;
fn map_remaining<F: FnOnce(&Self::Remaining) -> O, O>(&self, f: F) -> O;
fn take_map<F: FnOnce(Self::Head) -> Result<(Self::Head, O), E>, O, E>(
self,
f: F,
) -> Result<(Self, O), E>
where Self: Sized;
fn map_mut<F: FnOnce(&mut Self::Head) -> O, O>(&mut self, f: F) -> O;
}Expand description
Trait that defines a stack to store the results computed by forward propagation when training a neural network.
Required Associated Types§
Required Methods§
Sourcefn pop(self) -> (Self::Remaining, Self::Head)
fn pop(self) -> (Self::Remaining, Self::Head)
Returns a tuple of the top item in the stack and the rest of the stack
Sourcefn map<F: FnOnce(&Self::Head) -> O, O>(&self, f: F) -> O
fn map<F: FnOnce(&Self::Head) -> O, O>(&self, f: F) -> O
Returns the result of applying the callback function to the top element of the stack
§Arguments
f- Applicable callbacks
Sourcefn map_remaining<F: FnOnce(&Self::Remaining) -> O, O>(&self, f: F) -> O
fn map_remaining<F: FnOnce(&Self::Remaining) -> O, O>(&self, f: F) -> O
Returns the result of applying the callback to a stack that does not contain the top element of the stack
f- Applicable callbacks
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.