mextend_sp
All checks were successful
buildbot/fmt-check Build done.
buildbot/runtests Build done.
buildbot/rustdoc Build done.
buildbot/clippy Build done.

This commit is contained in:
AF 2023-08-05 13:11:06 +00:00
parent 4adb021a14
commit eb9a35f367

View File

@ -176,7 +176,7 @@ where
pub fn mdeserialize_sp<I: InCtx<'a, Ctx>>( pub fn mdeserialize_sp<I: InCtx<'a, Ctx>>(
factory_data: &SP::FactoryData, factory_data: &SP::FactoryData,
inctx: I, 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 (fa, fb) = SP::factories(factory_data);
let (a, inctx) = fa let (a, inctx) = fa
.ideserialize(inctx) .ideserialize(inctx)
@ -187,6 +187,21 @@ where
|b| SP::from_parsed(factory_data, a, b), |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> impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryModeParse<'a, Ctx>
@ -206,16 +221,13 @@ where
mentionable: ExtensionSourceM<'a, Ctx, Self>, mentionable: ExtensionSourceM<'a, Ctx, Self>,
tail: &[u8], tail: &[u8],
) -> ExtensionResultM<'a, Ctx, Self> { ) -> ExtensionResultM<'a, Ctx, Self> {
let (_, fb) = SP::factories(&self.factory_data); Self::xbind(
Self::xsbind( Self::mextend_sp(
mentionable, &self.factory_data,
|StaticPairObject { pair }| pair.into_elements(), Self::smap(mentionable, |StaticPairObject { pair }| pair),
|b| { tail,
Self::xmap_err(fb.mextend(b, tail), |e| { ),
SP::from_error_b(&self.factory_data, e) |pair| Ok(StaticPairObject { pair }),
})
},
|a, b| SP::from_parsed(&self.factory_data, a, b).map(|pair| StaticPairObject { pair }),
) )
} }
} }