pub trait Updatable {
// Required methods
fn updatable_states_len(&self) -> usize;
fn updatable_states(&self) -> impl IntoIterator<Item = &Array>;
fn updatable_states_mut(&mut self) -> impl IntoIterator<Item = &mut Array>;
}
Expand description
Helper trait for compiling a function that takes a Module and/or an Optimizer. The implementation must ensure consistent ordering of the returned states.
This is automatically implemented for all types that implement ModuleParameters.
Required Methods§
Sourcefn updatable_states_len(&self) -> usize
fn updatable_states_len(&self) -> usize
Returns the number of updatable states.
The number should be the same as calling self.updatable_states().len()
but
this method should be more efficient in general. The implementation should
avoid iterating over the states if possible.
Sourcefn updatable_states(&self) -> impl IntoIterator<Item = &Array>
fn updatable_states(&self) -> impl IntoIterator<Item = &Array>
Returns a list of references to the updatable states.
The order of the states should be consistent across calls and should be the same as the
order of the states returned by Updatable::updatable_states_mut
.
Sourcefn updatable_states_mut(&mut self) -> impl IntoIterator<Item = &mut Array>
fn updatable_states_mut(&mut self) -> impl IntoIterator<Item = &mut Array>
Returns a list of mutable references to the updatable states.
The order of the states should be consistent across calls and should be the same as the
order of the states returned by Updatable::updatable_states
.
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.