//! Shorthands for using [`Context::Fallible`]. use fail::*; use crate::func::context::*; use super::*; /// Preferred [Wrapped] [Result]. pub type FallibleWrapped<'a, Ctx, A, E> = Wrap<'a, A, FallibleMonad<'a, Ctx, E>>; /// Extention trait for simpler conversion between [`FunctorContext::T`] and [`Context::Fallible`]. /// /// Until either Rust type system or [`crate::func`] take serious changes, /// this is the preferred way to switch between [Wrapped] and [fallible]. pub trait FallibleContext<'a>: Context<'a> { /// Convert a fallible wrapped into a wrapped result. fn unstuff(wa: FallibleWrapped<'a, Self, A, E>) -> WrapC<'a, Result, Self> { >::Fallible::unstuff(wa) } /// Convert a wrapped result into a fallible wrapped. fn stuff(fa: WrapC<'a, Result, Self>) -> FallibleWrapped<'a, Self, A, E> { >::Fallible::stuff(fa) } } impl<'a, Ctx: Context<'a>> FallibleContext<'a> for Ctx {}