ParseModeExt::seal

This commit is contained in:
AF 2023-07-30 14:06:02 +00:00
parent b0b3cc1fe0
commit 1536f38f0b

View File

@ -112,6 +112,10 @@ pub trait ParseModeExt: ParseMode {
<Self::Mode as Mode>::map(s, f)
}
fn seal<A, I>(s: <Self::Mode as Mode>::ParseSuccess<A, I>) -> A {
<Self::Mode as Mode>::seal(s)
}
fn smap<A0, A1>(
source: <Self::Mode as Mode>::ExtensionSource<A0>,
f: impl FnOnce(A0) -> A1,
@ -142,8 +146,7 @@ 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.mdeserialize(inctx)
.map(<<Self as ParseMode>::Mode as Mode>::seal)
self.mdeserialize(inctx).map(Self::seal)
}
fn extend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {