From 4a762dd00fd44ca290c118794614e099a485fa0c Mon Sep 17 00:00:00 2001 From: timofey Date: Sat, 29 Jul 2023 18:33:40 +0000 Subject: [PATCH] `Mode::seal` --- src/rcore/modes.rs | 6 ++++++ src/rstd/inlining/modes.rs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/rcore/modes.rs b/src/rcore/modes.rs index cf8eb40..0286d49 100644 --- a/src/rcore/modes.rs +++ b/src/rcore/modes.rs @@ -14,6 +14,8 @@ pub trait Mode { result: Self::ParseResult, f: impl FnOnce(A0) -> Result, ) -> Self::ParseResult; + + fn seal(result: Self::ParseResult) -> Result; } pub trait ParseMode { @@ -79,6 +81,10 @@ impl Mode for RegularMode { ) -> Self::ParseResult { result.and_then(f) } + + fn seal(result: Self::ParseResult) -> Result { + result + } } pub trait RegularFactory<'a, Ctx: Context<'a>>: diff --git a/src/rstd/inlining/modes.rs b/src/rstd/inlining/modes.rs index 7ac123b..10f3d95 100644 --- a/src/rstd/inlining/modes.rs +++ b/src/rstd/inlining/modes.rs @@ -20,6 +20,10 @@ impl Mode for InliningMode { let a1 = f(a0)?; Ok((a1, i)) } + + fn seal(result: Self::ParseResult) -> Result { + result.map(|(a, _)| a) + } } impl<'a, Ctx: Context<'a>, F: InlineableFactory<'a, Ctx>> FactoryProxy<'a, Ctx>