pub enum State<Y, T> {
Yield(Y),
Complete(T),
}
Expand description
Represents the state of a coroutine, which can either yield a value of type Y
or complete with
a value of type T
.
Variants§
Yield(Y)
The coroutine yielded a value of type Y
.
Complete(T)
The coroutine completed with a value of type T
.
Implementations§
Source§impl<Y, T> State<Y, T>
impl<Y, T> State<Y, T>
Sourcepub fn as_yield(&self) -> Option<&Y>
pub fn as_yield(&self) -> Option<&Y>
Returns Some
with the yielded value if the state is [Yield
], otherwise None
.
Sourcepub fn as_complete(&self) -> Option<&T>
pub fn as_complete(&self) -> Option<&T>
Returns Some
with the completed value if the state is [Complete
], otherwise None
.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns true
if the state is [Complete
].
Trait Implementations§
impl<Y: Eq, T: Eq> Eq for State<Y, T>
impl<Y, T> StructuralPartialEq for State<Y, T>
Auto Trait Implementations§
impl<Y, T> Freeze for State<Y, T>
impl<Y, T> RefUnwindSafe for State<Y, T>where
Y: RefUnwindSafe,
T: RefUnwindSafe,
impl<Y, T> Send for State<Y, T>
impl<Y, T> Sync for State<Y, T>
impl<Y, T> Unpin for State<Y, T>
impl<Y, T> UnwindSafe for State<Y, T>where
Y: 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
Mutably borrows from an owned value. Read more