move FallibleCtxExt to func::context

This commit is contained in:
AF 2023-07-06 03:47:42 +00:00
parent 0a0d17c34d
commit 49cfeea849
4 changed files with 17 additions and 26 deletions

View File

@ -52,3 +52,20 @@ pub type FallibleMonad<'a, Ctx, E> = <<Ctx as FallibleCtx<'a>>::Fallible as Mona
/// Preferred [Wrap]ped [Result]. /// Preferred [Wrap]ped [Result].
pub type FallibleWrapped<'a, Ctx, A, E> = Wrap<'a, A, FallibleMonad<'a, Ctx, E>>; pub type FallibleWrapped<'a, Ctx, A, E> = Wrap<'a, A, FallibleMonad<'a, Ctx, E>>;
/// Extention trait for simpler conversion between [`FunctorContext::T`] and [`FallibleCtx::Fallible`].
///
/// this is the preferred way to switch between [WrapC] and [FallibleWrapped].
pub trait FallibleCtxExt<'a>: FallibleCtx<'a> {
/// Convert a fallible wrapped into a wrapped result.
fn unstuff<A: 'a, E: 'a>(wa: FallibleWrapped<'a, Self, A, E>) -> WrapC<'a, Result<A, E>, Self> {
Self::Fallible::unstuff(wa)
}
/// Convert a wrapped result into a fallible wrapped.
fn stuff<A: 'a, E: 'a>(fa: WrapC<'a, Result<A, E>, Self>) -> FallibleWrapped<'a, Self, A, E> {
Self::Fallible::stuff(fa)
}
}
impl<'a, Ctx: FallibleCtx<'a>> FallibleCtxExt<'a> for Ctx {}

View File

@ -3,7 +3,6 @@
pub mod atomic; pub mod atomic;
pub mod cast; pub mod cast;
pub mod collections; pub mod collections;
pub mod fallible;
pub mod inject; pub mod inject;
pub mod inlining; pub mod inlining;
mod local_origin; mod local_origin;

View File

@ -7,7 +7,6 @@ use crate::{
}, },
func::context::*, func::context::*,
rcore::*, rcore::*,
rstd::fallible::*,
}; };
use super::*; use super::*;

View File

@ -1,24 +0,0 @@
//! Shorthands for using [`Context::Fallible`].
use fail::*;
use crate::func::context::*;
use super::*;
/// Extention trait for simpler conversion between [`FunctorContext::T`] and [`FallibleCtx::Fallible`].
///
/// this is the preferred way to switch between [WrapC] and [FallibleWrapped].
pub trait FallibleCtxExt<'a>: FallibleCtx<'a> {
/// Convert a fallible wrapped into a wrapped result.
fn unstuff<A: 'a, E: 'a>(wa: FallibleWrapped<'a, Self, A, E>) -> WrapC<'a, Result<A, E>, Self> {
Self::Fallible::unstuff(wa)
}
/// Convert a wrapped result into a fallible wrapped.
fn stuff<A: 'a, E: 'a>(fa: WrapC<'a, Result<A, E>, Self>) -> FallibleWrapped<'a, Self, A, E> {
Self::Fallible::stuff(fa)
}
}
impl<'a, Ctx: FallibleCtx<'a>> FallibleCtxExt<'a> for Ctx {}