pub enum Successor<T, U = T> {
Continue(U),
Terminate,
Interrupt(T),
}
Expand description
The successor state or outcome of an episode step.
The purpose of the second generic parameter U
is to control the ownership of the following
state or observation when the episode continues. By default the successor is owned but it can
also be borrowed U = &T
or omitted U = ()
. This is useful because users might want to
extract the next observation without copying.
Variants
Continue(U)
The episode continues with the given state.
Terminate
The episode ends by entering a terminal state.
A terminal state is one from which all possible trajectories would have 0 reward.
Interrupt(T)
The episode ends despite entering the given non-terminal state.
Had the episode continued, non-zero future rewards might have been possible. For example, the episode may have been interrupted due to a step limit.
Implementations
sourceimpl<T, U> Successor<T, U>
impl<T, U> Successor<T, U>
sourcepub fn into_continue(self) -> Option<U>
pub fn into_continue(self) -> Option<U>
Unwrap into the contained Continue
value if possible.
sourcepub fn into_interrupt(self) -> Option<T>
pub fn into_interrupt(self) -> Option<T>
Unwrap into the contained Interrupt
value if possible.
sourcepub const fn episode_done(&self) -> bool
pub const fn episode_done(&self) -> bool
Whether this successor marks the end of an episode
sourcepub fn into_partial(self) -> PartialSuccessor<T>
pub fn into_partial(self) -> PartialSuccessor<T>
Drop any stored Continue
state, converting into PartialSuccessor
.
sourcepub fn map_continue<F, V>(self, f: F) -> Successor<T, V> where
F: FnOnce(U) -> V,
pub fn map_continue<F, V>(self, f: F) -> Successor<T, V> where
F: FnOnce(U) -> V,
Apply a function to just the successor Continue
variant.
sourcepub fn into_partial_continue(self) -> (PartialSuccessor<T>, Option<U>)
pub fn into_partial_continue(self) -> (PartialSuccessor<T>, Option<U>)
Partition into a PartialSuccessor
and the Continue
state, if any.
sourceimpl<T> Successor<T>
impl<T> Successor<T>
sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Successor<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Successor<U>
Apply a transformation to the inner state when present.
sourcepub fn then_interrupt_if<F>(self, f: F) -> Self where
F: FnOnce(&T) -> bool,
pub fn then_interrupt_if<F>(self, f: F) -> Self where
F: FnOnce(&T) -> bool,
Interrupt the successor if it is Continue
and the condition evaluates true.
sourcepub fn into_inner(self) -> Option<T>
pub fn into_inner(self) -> Option<T>
Get the inner state of Continue
and Interrupt
variants.
Trait Implementations
sourceimpl<'de, T, U> Deserialize<'de> for Successor<T, U> where
T: Deserialize<'de>,
U: Deserialize<'de>,
impl<'de, T, U> Deserialize<'de> for Successor<T, U> where
T: Deserialize<'de>,
U: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Copy, U: Copy> Copy for Successor<T, U>
impl<T: Eq, U: Eq> Eq for Successor<T, U>
impl<T, U> StructuralEq for Successor<T, U>
impl<T, U> StructuralPartialEq for Successor<T, U>
Auto Trait Implementations
impl<T, U> RefUnwindSafe for Successor<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Successor<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for Successor<T, U> where
T: Sync,
U: Sync,
impl<T, U> Unpin for Successor<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for Successor<T, U> where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.