use super::act::Act;
use core::{
ops::{
FromResidual,
Residual,
Try,
ControlFlow
},
mem::transmute_neo as transmute
};
pub struct Break;
impl<Type> const FromResidual<Break> for Act<Type> {
fn from_residual(_residual: Break) -> Self {return unsafe {transmute(None::<Type>)}}
}
impl<Type> Residual<Type> for Break {
type TryType = Act<Type>;
}
impl<Type> Try for Act<Type> {
type Output = Type;
type Residual = Break;
fn from_output(output: Self::Output) -> Self {return unsafe {transmute(Some(output))}}
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {return if let Some(value) = self.value() {
ControlFlow::Continue(value)
} else {ControlFlow::Break(Break)}}
}