mdeserialize_sp
This commit is contained in:
parent
1cb0f4042b
commit
c7d69b9982
@ -169,21 +169,33 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> ParseMode for StaticPairFact
|
|||||||
type Mode = <SP::FB as ParseMode>::Mode;
|
type Mode = <SP::FB as ParseMode>::Mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> StaticPairFactory<'a, Ctx, SP>
|
||||||
|
where
|
||||||
|
SP::FB: FactoryModeParse<'a, Ctx>,
|
||||||
|
{
|
||||||
|
pub fn mdeserialize_sp<I: InCtx<'a, Ctx>>(
|
||||||
|
factory_data: &SP::FactoryData,
|
||||||
|
inctx: I,
|
||||||
|
) -> ModeResultM<'a, Ctx, Self, I> {
|
||||||
|
let (fa, fb) = SP::factories(factory_data);
|
||||||
|
let (a, inctx) = fa
|
||||||
|
.ideserialize(inctx)
|
||||||
|
.map_err(|e| SP::from_error_a(factory_data, e))?;
|
||||||
|
Self::bind(
|
||||||
|
fb.mdeserialize(inctx)
|
||||||
|
.map_err(|e| SP::from_error_b(factory_data, e))?,
|
||||||
|
|b| SP::from_parsed(factory_data, a, b).map(|pair| StaticPairObject { pair }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryModeParse<'a, Ctx>
|
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryModeParse<'a, Ctx>
|
||||||
for StaticPairFactory<'a, Ctx, SP>
|
for StaticPairFactory<'a, Ctx, SP>
|
||||||
where
|
where
|
||||||
SP::FB: FactoryModeParse<'a, Ctx>,
|
SP::FB: FactoryModeParse<'a, Ctx>,
|
||||||
{
|
{
|
||||||
fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ModeResultM<'a, Ctx, Self, I> {
|
fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ModeResultM<'a, Ctx, Self, I> {
|
||||||
let (fa, fb) = SP::factories(&self.factory_data);
|
Self::mdeserialize_sp(&self.factory_data, inctx)
|
||||||
let (a, inctx) = fa
|
|
||||||
.ideserialize(inctx)
|
|
||||||
.map_err(|e| SP::from_error_a(&self.factory_data, e))?;
|
|
||||||
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 mextend(
|
fn mextend(
|
||||||
|
Loading…
Reference in New Issue
Block a user