diff --git a/src/rcore.rs b/src/rcore.rs index f928710..b503b3d 100644 --- a/src/rcore.rs +++ b/src/rcore.rs @@ -34,7 +34,8 @@ pub use self::inctx::InCtx; pub use self::inlining::{Inlining, InliningExt, InliningResultExt}; pub use self::modes::{ ExtensionResultM, ExtensionSourceM, FactoryModeParse, FactoryModeProxy, ImplMode, Mode, - ParseMode, ParseResultM, QRegularFactory, RegularFactory, RegularMode, WithMode, WithParseMode, + ModeResult, ParseMode, ParseModeExt, ParseResultM, QRegularFactory, RegularFactory, + RegularMode, WithMode, WithParseMode, }; pub use self::origin::{OFctr, Origin}; pub use self::point::Point; diff --git a/src/rcore/modes.rs b/src/rcore/modes.rs index 3fbfc38..9f7a6af 100644 --- a/src/rcore/modes.rs +++ b/src/rcore/modes.rs @@ -2,24 +2,26 @@ use std::marker::PhantomData; use super::*; +pub type ModeResult<M, A, E, I> = Result<<M as Mode>::ParseSuccess<A, I>, E>; + pub trait Mode { - type ParseResult<A, E, I>; + type ParseSuccess<A, I>; type ExtensionResult<A, E>; - type ExtensionSource<A, E>; - - fn map_err<A, E0, E1, I>( - result: Self::ParseResult<A, E0, I>, - f: impl FnOnce(E0) -> E1, - ) -> Self::ParseResult<A, E1, I>; + type ExtensionSource<A>; fn bind<A0, A1, E, I>( - result: Self::ParseResult<A0, E, I>, + s: Self::ParseSuccess<A0, I>, f: impl FnOnce(A0) -> Result<A1, E>, - ) -> Self::ParseResult<A1, E, I>; + ) -> ModeResult<Self, A1, E, I>; - fn seal<A, E, I>(result: Self::ParseResult<A, E, I>) -> Result<A, E>; + fn map<A0, A1, I>( + s: Self::ParseSuccess<A0, I>, + f: impl FnOnce(A0) -> A1, + ) -> Self::ParseSuccess<A1, I>; + + fn seal<A, I>(s: Self::ParseSuccess<A, I>) -> A; fn xmap_err<A, E0, E1>( result: Self::ExtensionResult<A, E0>, @@ -33,16 +35,50 @@ pub trait Mode { fn xseal<A, E>(result: Self::ExtensionResult<A, E>) -> Result<A, E>; - fn smap<A0, A1, E>( - source: Self::ExtensionSource<A0, E>, + fn smap<A0, A1>( + source: Self::ExtensionSource<A0>, f: impl FnOnce(A0) -> A1, - ) -> Self::ExtensionSource<A1, E>; + ) -> Self::ExtensionSource<A1>; + + fn prepare<A>(a: A) -> Self::ExtensionSource<A>; + + fn xsbind<AB, A, B, E>( + ab: Self::ExtensionSource<AB>, + t2ab: impl FnOnce(AB) -> (A, B), + ce: impl FnOnce(Self::ExtensionSource<B>) -> Self::ExtensionResult<B, E>, + ab2t: impl FnOnce(A, B) -> Result<AB, E>, + ) -> Self::ExtensionResult<AB, E>; } pub trait ParseMode { type Mode: ?Sized + Mode; } +pub trait ParseModeExt: ParseMode { + fn bind<A0, A1, E, I>( + s: <Self::Mode as Mode>::ParseSuccess<A0, I>, + f: impl FnOnce(A0) -> Result<A1, E>, + ) -> ModeResult<Self::Mode, A1, E, I> { + <Self::Mode as Mode>::bind(s, f) + } + + fn map<A0, A1, I>( + s: <Self::Mode as Mode>::ParseSuccess<A0, I>, + f: impl FnOnce(A0) -> A1, + ) -> <Self::Mode as Mode>::ParseSuccess<A1, I> { + <Self::Mode as Mode>::map(s, f) + } + + fn smap<A0, A1>( + source: <Self::Mode as Mode>::ExtensionSource<A0>, + f: impl FnOnce(A0) -> A1, + ) -> <Self::Mode as Mode>::ExtensionSource<A1> { + <Self::Mode as Mode>::smap(source, f) + } +} + +impl<F: ParseMode> ParseModeExt for F {} + pub trait WithParseMode: ParseMode { type WithMode: ?Sized; } @@ -63,11 +99,15 @@ 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 as ParseMode>::Mode as Mode>::seal(self.mdeserialize(inctx)) + self.mdeserialize(inctx) + .map(<<Self as ParseMode>::Mode as Mode>::seal) } fn extend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> { - <<Self as ParseMode>::Mode as Mode>::xseal(self.mextend(Self::mprepare(mentionable), tail)) + <<Self as ParseMode>::Mode as Mode>::xseal(self.mextend( + <<Self as ParseMode>::Mode as Mode>::prepare(mentionable), + tail, + )) } } @@ -79,13 +119,13 @@ where } pub type ParseResultM<'a, Ctx, F, I> = - <<F as ParseMode>::Mode as Mode>::ParseResult<Mtbl<'a, Ctx, F>, ParseError<'a, Ctx, F>, I>; + ModeResult<<F as ParseMode>::Mode, Mtbl<'a, Ctx, F>, ParseError<'a, Ctx, F>, I>; pub type ExtensionResultM<'a, Ctx, F> = <<F as ParseMode>::Mode as Mode>::ExtensionResult<Mtbl<'a, Ctx, F>, ParseError<'a, Ctx, F>>; pub type ExtensionSourceM<'a, Ctx, F> = - <<F as ParseMode>::Mode as Mode>::ExtensionSource<Mtbl<'a, Ctx, F>, ParseError<'a, Ctx, F>>; + <<F as ParseMode>::Mode as Mode>::ExtensionSource<Mtbl<'a, Ctx, F>>; pub trait FactoryModeParse<'a, Ctx: Context<'a>>: FactoryBase<'a, Ctx> + ParseMode { fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ParseResultM<'a, Ctx, Self, I>; @@ -95,8 +135,6 @@ pub trait FactoryModeParse<'a, Ctx: Context<'a>>: FactoryBase<'a, Ctx> + ParseMo mentionable: ExtensionSourceM<'a, Ctx, Self>, tail: &[u8], ) -> ExtensionResultM<'a, Ctx, Self>; - - fn mprepare(mentionable: Self::Mtbl) -> ExtensionSourceM<'a, Ctx, Self>; } pub trait FactoryModeProxy<'a, Ctx: Context<'a>> { @@ -110,8 +148,6 @@ pub trait FactoryModeProxy<'a, Ctx: Context<'a>> { mentionable: ExtensionSourceM<'a, Ctx, Self::F>, tail: &[u8], ) -> ExtensionResultM<'a, Ctx, Self::F>; - - fn pmprepare(mentionable: Mtbl<'a, Ctx, Self::F>) -> ExtensionSourceM<'a, Ctx, Self::F>; } impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx> + WithParseMode> FactoryModeParse<'a, Ctx> for F @@ -129,37 +165,33 @@ where ) -> ExtensionResultM<'a, Ctx, Self> { <F::WithMode as FactoryModeProxy<'a, Ctx>>::pmextend(self, mentionable, tail) } - - fn mprepare(mentionable: Self::Mtbl) -> ExtensionSourceM<'a, Ctx, Self> { - <F::WithMode as FactoryModeProxy<'a, Ctx>>::pmprepare(mentionable) - } } pub struct RegularMode; impl Mode for RegularMode { - type ParseResult<A, E, I> = Result<A, E>; + type ParseSuccess<A, I> = A; type ExtensionResult<A, E> = Result<A, E>; - type ExtensionSource<A, E> = A; - - fn map_err<A, E0, E1, I>( - result: Self::ParseResult<A, E0, I>, - f: impl FnOnce(E0) -> E1, - ) -> Self::ParseResult<A, E1, I> { - result.map_err(f) - } + type ExtensionSource<A> = A; fn bind<A0, A1, E, I>( - result: Self::ParseResult<A0, E, I>, + s: Self::ParseSuccess<A0, I>, f: impl FnOnce(A0) -> Result<A1, E>, - ) -> Self::ParseResult<A1, E, I> { - result.and_then(f) + ) -> ModeResult<Self, A1, E, I> { + f(s) } - fn seal<A, E, I>(result: Self::ParseResult<A, E, I>) -> Result<A, E> { - result + fn map<A0, A1, I>( + s: Self::ParseSuccess<A0, I>, + f: impl FnOnce(A0) -> A1, + ) -> Self::ParseSuccess<A1, I> { + f(s) + } + + fn seal<A, I>(s: Self::ParseSuccess<A, I>) -> A { + s } fn xmap_err<A, E0, E1>( @@ -180,12 +212,26 @@ impl Mode for RegularMode { result } - fn smap<A0, A1, E>( - source: Self::ExtensionSource<A0, E>, + fn smap<A0, A1>( + source: Self::ExtensionSource<A0>, f: impl FnOnce(A0) -> A1, - ) -> Self::ExtensionSource<A1, E> { + ) -> Self::ExtensionSource<A1> { f(source) } + + fn prepare<A>(a: A) -> Self::ExtensionSource<A> { + a + } + + fn xsbind<AB, A, B, E>( + ab: Self::ExtensionSource<AB>, + t2ab: impl FnOnce(AB) -> (A, B), + ce: impl FnOnce(Self::ExtensionSource<B>) -> Self::ExtensionResult<B, E>, + ab2t: impl FnOnce(A, B) -> Result<AB, E>, + ) -> Self::ExtensionResult<AB, E> { + let (b, c) = t2ab(ab); + ab2t(b, ce(c)?) + } } pub trait QRegularFactory<'a, Ctx: Context<'a>>: @@ -226,8 +272,4 @@ impl<'a, Ctx: Context<'a>, F: QRegularFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx fn pmextend(f: &F, mentionable: Mtbl<'a, Ctx, F>, tail: &[u8]) -> ExtensionResultM<'a, Ctx, F> { f.qrextend(mentionable, tail) } - - fn pmprepare(mentionable: Mtbl<'a, Ctx, Self::F>) -> ExtensionSourceM<'a, Ctx, Self::F> { - mentionable - } } diff --git a/src/rstd/atomic/atomic_object.rs b/src/rstd/atomic/atomic_object.rs index 906b9d1..f7596f8 100644 --- a/src/rstd/atomic/atomic_object.rs +++ b/src/rstd/atomic/atomic_object.rs @@ -81,7 +81,7 @@ impl<A: ParseMode> ParseMode for AtomicFactory<A> { impl<'a, Ctx: Context<'a>, A: AtomicModeParse> FactoryModeParse<'a, Ctx> for AtomicFactory<A> { fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ParseResultM<'a, Ctx, Self, I> { - <<A as ParseMode>::Mode as Mode>::bind(A::ma_deserialize(inctx), |a| Ok(a.into())) + <<A as ParseMode>::Mode as Mode>::bind(A::ma_deserialize(inctx)?, |a| Ok(a.into())) } fn mextend( @@ -97,10 +97,6 @@ impl<'a, Ctx: Context<'a>, A: AtomicModeParse> FactoryModeParse<'a, Ctx> for Ato |a| Ok(a.into()), ) } - - fn mprepare(mentionable: Self::Mtbl) -> ExtensionSourceM<'a, Ctx, Self> { - <<A as ParseMode>::Mode as Mode>::smap(mentionable.atomic.ma_prepare(), |a| a.into()) - } } /// Extension trait to provide method-like utilities associated with [AtomicObject]s. diff --git a/src/rstd/atomic/modes.rs b/src/rstd/atomic/modes.rs index 9b81abc..9706bd4 100644 --- a/src/rstd/atomic/modes.rs +++ b/src/rstd/atomic/modes.rs @@ -2,28 +2,25 @@ use super::*; impl<A: AtomicModeParse> Atomic for A { fn a_deserialize(inlining: impl Inlining) -> AParseResult<Self> { - <A::Mode as Mode>::seal(Self::ma_deserialize(inlining)) + Self::ma_deserialize(inlining).map(<A::Mode as Mode>::seal) } fn a_extend(self, tail: &[u8]) -> AParseResult<Self> { - <A::Mode as Mode>::xseal(Self::ma_extend(self.ma_prepare(), tail)) + <A::Mode as Mode>::xseal(Self::ma_extend(<A::Mode as Mode>::prepare(self), tail)) } } -pub type AParseResultM<A, I> = <<A as ParseMode>::Mode as Mode>::ParseResult<A, AParseError<A>, I>; +pub type AParseResultM<A, I> = ModeResult<<A as ParseMode>::Mode, A, AParseError<A>, I>; pub type AExtensionResultM<A> = <<A as ParseMode>::Mode as Mode>::ExtensionResult<A, AParseError<A>>; -pub type AExtensionSourceM<A> = - <<A as ParseMode>::Mode as Mode>::ExtensionSource<A, AParseError<A>>; +pub type AExtensionSourceM<A> = <<A as ParseMode>::Mode as Mode>::ExtensionSource<A>; pub trait AtomicModeParse: AtomicBase + ParseMode { fn ma_deserialize<I: Inlining>(inlining: I) -> AParseResultM<Self, I>; fn ma_extend(atomic: AExtensionSourceM<Self>, tail: &[u8]) -> AExtensionResultM<Self>; - - fn ma_prepare(self) -> AExtensionSourceM<Self>; } pub trait AtomicModeProxy { @@ -32,8 +29,6 @@ pub trait AtomicModeProxy { fn pma_deserialize<I: Inlining>(inlining: I) -> AParseResultM<Self::A, I>; fn pma_extend(atomic: AExtensionSourceM<Self::A>, tail: &[u8]) -> AExtensionResultM<Self::A>; - - fn pma_prepare(atomic: Self::A) -> AExtensionSourceM<Self::A>; } impl<A: AtomicBase + WithParseMode> AtomicModeParse for A @@ -47,10 +42,6 @@ where fn ma_extend(atomic: AExtensionSourceM<Self>, tail: &[u8]) -> AExtensionResultM<Self> { <<A as WithParseMode>::WithMode as AtomicModeProxy>::pma_extend(atomic, tail) } - - fn ma_prepare(self) -> AExtensionSourceM<Self> { - <<A as WithParseMode>::WithMode as AtomicModeProxy>::pma_prepare(self) - } } pub trait RegularAtomic: AtomicBase + ParseMode<Mode = RegularMode> { @@ -68,8 +59,4 @@ impl<A: RegularAtomic> AtomicModeProxy for WithMode<A, RegularMode> { fn pma_extend(atomic: AExtensionSourceM<Self::A>, tail: &[u8]) -> AExtensionResultM<Self::A> { atomic.ra_extend(tail) } - - fn pma_prepare(atomic: Self::A) -> AExtensionSourceM<Self::A> { - atomic - } } diff --git a/src/rstd/collections/pair.rs b/src/rstd/collections/pair.rs index e1ab377..ff4bfdd 100644 --- a/src/rstd/collections/pair.rs +++ b/src/rstd/collections/pair.rs @@ -60,8 +60,12 @@ where (&factory_data.0, &factory_data.1) } - fn from_parsed(_factory_data: &Self::FactoryData, a: Self::A, b: Self::B) -> Self { - (a, b) + fn from_parsed( + _factory_data: &Self::FactoryData, + a: Self::A, + b: Self::B, + ) -> Result<Self, Self::ParseError> { + Ok((a, b)) } fn from_error_a( diff --git a/src/rstd/inlining/modes.rs b/src/rstd/inlining/modes.rs index 226980b..d78bee5 100644 --- a/src/rstd/inlining/modes.rs +++ b/src/rstd/inlining/modes.rs @@ -3,30 +3,30 @@ use super::*; pub struct InliningMode; impl Mode for InliningMode { - type ParseResult<A, E, I> = Result<(A, I), E>; + type ParseSuccess<A, I> = (A, I); type ExtensionResult<A, E> = E; - type ExtensionSource<A, E> = (); - - fn map_err<A, E0, E1, I>( - result: Self::ParseResult<A, E0, I>, - f: impl FnOnce(E0) -> E1, - ) -> Self::ParseResult<A, E1, I> { - result.map_err(f) - } + type ExtensionSource<A> = (); fn bind<A0, A1, E, I>( - result: Self::ParseResult<A0, E, I>, + s: Self::ParseSuccess<A0, I>, f: impl FnOnce(A0) -> Result<A1, E>, - ) -> Self::ParseResult<A1, E, I> { - let (a0, i) = result?; + ) -> ModeResult<Self, A1, E, I> { + let (a0, i) = s; let a1 = f(a0)?; Ok((a1, i)) } - fn seal<A, E, I>(result: Self::ParseResult<A, E, I>) -> Result<A, E> { - result.map(|(a, _)| a) + fn map<A0, A1, I>( + s: Self::ParseSuccess<A0, I>, + f: impl FnOnce(A0) -> A1, + ) -> Self::ParseSuccess<A1, I> { + (f(s.0), s.1) + } + + fn seal<A, I>(s: Self::ParseSuccess<A, I>) -> A { + s.0 } fn xmap_err<A, E0, E1>( @@ -47,12 +47,23 @@ impl Mode for InliningMode { Err(result) } - fn smap<A0, A1, E>( - source: Self::ExtensionSource<A0, E>, + fn smap<A0, A1>( + source: Self::ExtensionSource<A0>, _f: impl FnOnce(A0) -> A1, - ) -> Self::ExtensionSource<A1, E> { + ) -> Self::ExtensionSource<A1> { source } + + fn prepare<A>(_a: A) -> Self::ExtensionSource<A> {} + + fn xsbind<AB, A, B, E>( + _ab: Self::ExtensionSource<AB>, + _t2ab: impl FnOnce(AB) -> (A, B), + ce: impl FnOnce(Self::ExtensionSource<B>) -> Self::ExtensionResult<B, E>, + _ab2t: impl FnOnce(A, B) -> Result<AB, E>, + ) -> Self::ExtensionResult<AB, E> { + ce(()) + } } impl<'a, Ctx: Context<'a>, F: QInliningFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx> @@ -71,8 +82,6 @@ impl<'a, Ctx: Context<'a>, F: QInliningFactory<'a, Ctx>> FactoryModeProxy<'a, Ct ) -> ExtensionResultM<'a, Ctx, F> { f.qextension_error(tail) } - - fn pmprepare(_mentionable: Mtbl<'a, Ctx, Self::F>) -> ExtensionSourceM<'a, Ctx, Self::F> {} } impl<A: QInliningAtomic> AtomicModeProxy for WithMode<A, InliningMode> { @@ -85,6 +94,4 @@ impl<A: QInliningAtomic> AtomicModeProxy for WithMode<A, InliningMode> { fn pma_extend(_atomic: AExtensionSourceM<Self::A>, tail: &[u8]) -> AExtensionResultM<Self::A> { A::qa_extension_error(tail) } - - fn pma_prepare(_atomic: Self::A) -> AExtensionSourceM<Self::A> {} } diff --git a/src/rstd/inlining/static_pair.rs b/src/rstd/inlining/static_pair.rs index ae3e2cc..28a3b6d 100644 --- a/src/rstd/inlining/static_pair.rs +++ b/src/rstd/inlining/static_pair.rs @@ -29,7 +29,7 @@ pub trait StaticPairSerializable { /// /// Note: [`StaticPair::FA`] requires [`InliningFactory`] be implemented. pub trait StaticPair<'a, Ctx: Context<'a>>: - 'a + StaticPairSerializable<SA = Self::A, SB = Self::B> + 'a + StaticPairSerializable<SA = Self::A, SB = Self::B> + Sized { /// [Factory] data. May, depending on the usecase, include factory (factories) on the element(s). type FactoryData: 'a + Send + Sync + Clone; @@ -47,7 +47,11 @@ pub trait StaticPair<'a, Ctx: Context<'a>>: /// Borrow both elements' factories. fn factories(factory_data: &Self::FactoryData) -> (&Self::FA, &Self::FB); /// Construct the object from the elements. - fn from_parsed(factory_data: &Self::FactoryData, a: Self::A, b: Self::B) -> Self; + fn from_parsed( + factory_data: &Self::FactoryData, + a: Self::A, + b: Self::B, + ) -> Result<Self, Self::ParseError>; /// Regularise the error returned while parsing the first element. fn from_error_a( factory_data: &Self::FactoryData, @@ -140,62 +144,43 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryBase<'a, Ctx> type ParseError = SP::ParseError; } -impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> ImplMode for StaticPairFactory<'a, Ctx, SP> { +impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> ParseMode for StaticPairFactory<'a, Ctx, SP> { type Mode = <SP::FB as ParseMode>::Mode; } -impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> QRegularFactory<'a, Ctx> +impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryModeParse<'a, Ctx> for StaticPairFactory<'a, Ctx, SP> where - SP::FB: RegularFactory<'a, Ctx>, + SP::FB: FactoryModeParse<'a, Ctx>, { - fn qrdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> { + fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ParseResultM<'a, Ctx, Self, I> { let (fa, fb) = SP::factories(&self.factory_data); let (a, inctx) = fa .ideserialize(inctx) .map_err(|e| SP::from_error_a(&self.factory_data, e))?; - let b = fb - .rdeserialize(inctx) - .map_err(|e| SP::from_error_b(&self.factory_data, e))?; - Ok(StaticPairObject { - pair: SP::from_parsed(&self.factory_data, a, b), - }) + Self::bind( + fb.mdeserialize(inctx) + .map_err(|e| SP::from_error_b(&self.factory_data, e))?, + |b| SP::from_parsed(&self.factory_data, a, b).map(|pair| StaticPairObject { pair }), + ) } - fn qrextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> { + fn mextend( + &self, + mentionable: ExtensionSourceM<'a, Ctx, Self>, + tail: &[u8], + ) -> ExtensionResultM<'a, Ctx, Self> { let (_, fb) = SP::factories(&self.factory_data); - let (a, b) = mentionable.pair.into_elements(); - match fb.rextend(b, tail) { - Ok(b) => Ok(SP::from_parsed(&self.factory_data, a, b).into()), - Err(e) => Err(SP::from_error_b(&self.factory_data, e)), - } - } -} - -impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> QInliningFactory<'a, Ctx> - for StaticPairFactory<'a, Ctx, SP> -where - SP::FB: InliningFactory<'a, Ctx>, -{ - fn qextension_error(&self, tail: &[u8]) -> Self::ParseError { - let (_, fb) = SP::factories(&self.factory_data); - SP::from_error_b(&self.factory_data, fb.extension_error(tail)) - } - - fn qideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> { - let (fa, fb) = SP::factories(&self.factory_data); - let (a, inctx) = fa - .ideserialize(inctx) - .map_err(|e| SP::from_error_a(&self.factory_data, e))?; - let (b, inctx) = fb - .ideserialize(inctx) - .map_err(|e| SP::from_error_b(&self.factory_data, e))?; - Ok(( - StaticPairObject { - pair: SP::from_parsed(&self.factory_data, a, b), + <Self::Mode as Mode>::xsbind( + mentionable, + |StaticPairObject { pair }| pair.into_elements(), + |b| { + <Self::Mode as Mode>::xmap_err(fb.mextend(b, tail), |e| { + SP::from_error_b(&self.factory_data, e) + }) }, - inctx, - )) + |a, b| SP::from_parsed(&self.factory_data, a, b).map(|pair| StaticPairObject { pair }), + ) } } @@ -203,7 +188,7 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FixedSizeFactory<'a, Ctx> for StaticPairFactory<'a, Ctx, SP> where SP::FA: FixedSizeFactory<'a, Ctx>, - SP::FB: FixedSizeFactory<'a, Ctx>, + SP::FB: FixedSizeFactory<'a, Ctx> + FactoryModeParse<'a, Ctx>, { fn size(&self) -> usize { let (fa, fb) = SP::factories(&self.factory_data); @@ -215,7 +200,7 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> ConstSizeFactory<'a, Ctx> for StaticPairFactory<'a, Ctx, SP> where SP::FA: ConstSizeFactory<'a, Ctx>, - SP::FB: ConstSizeFactory<'a, Ctx>, + SP::FB: ConstSizeFactory<'a, Ctx> + FactoryModeParse<'a, Ctx>, { const SIZE: usize = SP::FA::SIZE + SP::FB::SIZE; }