pub enum LoopResult<T> {
Again(T),
Done(T),
}Expand description
The result of a single loop iteration.
A task inside a loop_task must return LoopResult<T>:
Again(value)— feedvalueback as input to the next iteration.Done(value)— exit the loop;valuebecomes the loop’s output.
§Example
use sayiir_core::LoopResult;
fn refine(draft: String) -> LoopResult<String> {
if draft.len() > 100 {
LoopResult::Done(draft)
} else {
LoopResult::Again(format!("{draft} ...more"))
}
}Variants§
Again(T)
Continue looping with the wrapped value as the next iteration’s input.
Done(T)
Exit the loop with the wrapped value as the loop’s output.
Implementations§
Source§impl<T> LoopResult<T>
impl<T> LoopResult<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwrap the inner value regardless of variant.
Sourcepub fn into_decision(self) -> (LoopDecision, T)
pub fn into_decision(self) -> (LoopDecision, T)
Split into a LoopDecision and the inner value.
Trait Implementations§
Source§impl<T: Clone> Clone for LoopResult<T>
impl<T: Clone> Clone for LoopResult<T>
Source§fn clone(&self) -> LoopResult<T>
fn clone(&self) -> LoopResult<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for LoopResult<T>
impl<T: Debug> Debug for LoopResult<T>
Source§impl<'de, T> Deserialize<'de> for LoopResult<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for LoopResult<T>where
T: 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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> LoopOutput for LoopResult<T>
impl<T> LoopOutput for LoopResult<T>
Auto Trait Implementations§
impl<T> Freeze for LoopResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for LoopResult<T>where
T: RefUnwindSafe,
impl<T> Send for LoopResult<T>where
T: Send,
impl<T> Sync for LoopResult<T>where
T: Sync,
impl<T> Unpin for LoopResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for LoopResult<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for LoopResult<T>where
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