mextend_sp
This commit is contained in:
parent
4adb021a14
commit
eb9a35f367
@ -176,7 +176,7 @@ where
|
||||
pub fn mdeserialize_sp<I: InCtx<'a, Ctx>>(
|
||||
factory_data: &SP::FactoryData,
|
||||
inctx: I,
|
||||
) -> ModeResultP<Self, SP, <Self as FactoryBase<'a, Ctx>>::ParseError, I> {
|
||||
) -> ModeResultP<Self, SP, SP::ParseError, I> {
|
||||
let (fa, fb) = SP::factories(factory_data);
|
||||
let (a, inctx) = fa
|
||||
.ideserialize(inctx)
|
||||
@ -187,6 +187,21 @@ where
|
||||
|b| SP::from_parsed(factory_data, a, b),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mextend_sp(
|
||||
factory_data: &SP::FactoryData,
|
||||
mentionable: ExtensionSourceP<Self, SP>,
|
||||
tail: &[u8],
|
||||
) -> ExtensionResultP<Self, SP, SP::ParseError> {
|
||||
let (_, fb) = SP::factories(factory_data);
|
||||
// annotated to help rust-analyzer
|
||||
Self::xsbind::<SP, _, _, _>(
|
||||
mentionable,
|
||||
|pair| pair.into_elements(),
|
||||
|b| Self::xmap_err(fb.mextend(b, tail), |e| SP::from_error_b(factory_data, e)),
|
||||
|a, b| SP::from_parsed(factory_data, a, b),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryModeParse<'a, Ctx>
|
||||
@ -206,16 +221,13 @@ where
|
||||
mentionable: ExtensionSourceM<'a, Ctx, Self>,
|
||||
tail: &[u8],
|
||||
) -> ExtensionResultM<'a, Ctx, Self> {
|
||||
let (_, fb) = SP::factories(&self.factory_data);
|
||||
Self::xsbind(
|
||||
mentionable,
|
||||
|StaticPairObject { pair }| pair.into_elements(),
|
||||
|b| {
|
||||
Self::xmap_err(fb.mextend(b, tail), |e| {
|
||||
SP::from_error_b(&self.factory_data, e)
|
||||
})
|
||||
},
|
||||
|a, b| SP::from_parsed(&self.factory_data, a, b).map(|pair| StaticPairObject { pair }),
|
||||
Self::xbind(
|
||||
Self::mextend_sp(
|
||||
&self.factory_data,
|
||||
Self::smap(mentionable, |StaticPairObject { pair }| pair),
|
||||
tail,
|
||||
),
|
||||
|pair| Ok(StaticPairObject { pair }),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user