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§
Source§impl<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.
Source§impl<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
pub fn then_interrupt_if<F>(self, f: F) -> Self
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§
Source§impl<'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>,
Source§fn 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>,
impl<T: Copy, U: Copy> Copy for Successor<T, U>
impl<T: Eq, U: Eq> Eq for Successor<T, U>
impl<T, U> StructuralPartialEq for Successor<T, U>
Auto Trait Implementations§
impl<T, U> Freeze for Successor<T, U>
impl<T, U> RefUnwindSafe for Successor<T, U>where
U: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, U> Send for Successor<T, U>
impl<T, U> Sync for Successor<T, U>
impl<T, U> Unpin for Successor<T, U>
impl<T, U> UnwindSafe for Successor<T, U>where
U: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more