move WithMode
to mode
This commit is contained in:
parent
f07f0f3607
commit
5bc65753dd
25
src/mode.rs
25
src/mode.rs
@ -1,3 +1,5 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// See [`ModeResult`].
|
||||
pub type ParseSuccess<M, A, I> = <M as Mode>::ParseSuccess<A, I>;
|
||||
|
||||
@ -200,3 +202,26 @@ pub trait ImplMode {
|
||||
/// Same as [`ParseMode::Mode`]
|
||||
type Mode: ?Sized + Mode;
|
||||
}
|
||||
|
||||
/// Used with [`WithMode`] for linking [`ImplMode`] to [`FactoryParse`] and [`Atomic`].
|
||||
///
|
||||
/// [`FactoryParse`]: crate::rcore::FactoryParse
|
||||
/// [`Atomic`]: crate::rstd::atomic::Atomic
|
||||
pub trait WithParseMode: ImplMode {
|
||||
/// [`WithMode`] implementing [`FactoryModeProxy`] or [`AtomicModeProxy`].
|
||||
///
|
||||
/// [`FactoryModeProxy`]: crate::rcore::FactoryModeProxy
|
||||
/// [`AtomicModeProxy`]: crate::rstd::atomic::AtomicModeProxy
|
||||
type WithMode: ?Sized;
|
||||
}
|
||||
|
||||
impl<T: ?Sized + ImplMode> ParseMode for T {
|
||||
type Mode = <Self as ImplMode>::Mode;
|
||||
}
|
||||
|
||||
impl<T: ?Sized + ImplMode> WithParseMode for T {
|
||||
type WithMode = WithMode<Self, <Self as ParseMode>::Mode>;
|
||||
}
|
||||
|
||||
/// Used as [`WithParseMode::WithMode`].
|
||||
pub struct WithMode<T: ?Sized, M: ?Sized>(PhantomData<M>, T);
|
||||
|
@ -35,7 +35,7 @@ pub use self::inctx::InCtx;
|
||||
pub use self::inlining::{Inlining, InliningExt, InliningResultExt};
|
||||
pub use self::modes::{
|
||||
CRegularFactory, ExtensionResultM, ExtensionSourceM, FactoryModeParse, FactoryModeProxy,
|
||||
ModeResultM, RegularFactory, RegularMode, WithMode, WithParseMode,
|
||||
ModeResultM, RegularFactory, RegularMode,
|
||||
};
|
||||
pub use self::origin::{OFctr, Origin};
|
||||
pub use self::point::Point;
|
||||
|
@ -1,28 +1,5 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Used with [`WithMode`] for linking [`ImplMode`] to [`FactoryParse`] and [`Atomic`].
|
||||
///
|
||||
/// [`Atomic`]: crate::rstd::atomic::Atomic
|
||||
pub trait WithParseMode: ImplMode {
|
||||
/// [`WithMode`] implementing [`FactoryModeProxy`] or [`AtomicModeProxy`].
|
||||
///
|
||||
/// [`AtomicModeProxy`]: crate::rstd::atomic::AtomicModeProxy
|
||||
type WithMode: ?Sized;
|
||||
}
|
||||
|
||||
impl<T: ?Sized + ImplMode> ParseMode for T {
|
||||
type Mode = <Self as ImplMode>::Mode;
|
||||
}
|
||||
|
||||
impl<T: ?Sized + ImplMode> WithParseMode for T {
|
||||
type WithMode = WithMode<Self, <Self as ParseMode>::Mode>;
|
||||
}
|
||||
|
||||
/// Used as [`WithParseMode::WithMode`].
|
||||
pub struct WithMode<T: ?Sized, M: ?Sized>(PhantomData<M>, T);
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryModeParse<'a, Ctx>> FactoryParse<'a, Ctx> for F {
|
||||
fn deserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
self.mdeserialize(inctx).map(Self::seal)
|
||||
|
Loading…
Reference in New Issue
Block a user