diff --git a/src/mode.rs b/src/mode.rs index e2a2a41..15247c4 100644 --- a/src/mode.rs +++ b/src/mode.rs @@ -1,3 +1,5 @@ +use std::marker::PhantomData; + /// See [`ModeResult`]. pub type ParseSuccess = ::ParseSuccess; @@ -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 ParseMode for T { + type Mode = ::Mode; +} + +impl WithParseMode for T { + type WithMode = WithMode::Mode>; +} + +/// Used as [`WithParseMode::WithMode`]. +pub struct WithMode(PhantomData, T); diff --git a/src/rcore.rs b/src/rcore.rs index 36fa114..45bea6b 100644 --- a/src/rcore.rs +++ b/src/rcore.rs @@ -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; diff --git a/src/rcore/modes.rs b/src/rcore/modes.rs index ec00707..c74c7d6 100644 --- a/src/rcore/modes.rs +++ b/src/rcore/modes.rs @@ -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 ParseMode for T { - type Mode = ::Mode; -} - -impl WithParseMode for T { - type WithMode = WithMode::Mode>; -} - -/// Used as [`WithParseMode::WithMode`]. -pub struct WithMode(PhantomData, 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)