From 62b631d33dbe7b652fbb6324a1fbdfbf32f1c510 Mon Sep 17 00:00:00 2001 From: timofey Date: Sat, 1 Jul 2023 14:20:23 +0000 Subject: [PATCH] `InCtx::demote` --- src/rcore/inctx.rs | 13 +++++++++++++ src/rstd/inlining.rs | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/rcore/inctx.rs b/src/rcore/inctx.rs index 9f6b864..bbbfd80 100644 --- a/src/rcore/inctx.rs +++ b/src/rcore/inctx.rs @@ -20,6 +20,11 @@ pub trait InCtx<'a, Ctx: Context<'a>>: Inlining { /// Clone the reference to the current [Resolver]. fn iresolver(&self) -> Rc>; + + fn demote<'d>(self) -> Demoted<'a, 'd, Ctx> + where + 'a: 'd, + Self: 'd; } impl<'a: 'c, 'c, Ctx: Context<'a>> Inlining for &'c mut dyn DeCtx<'a, Ctx> { @@ -56,4 +61,12 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for &'c mut dyn DeCtx<'a, Ctx> fn iresolver(&self) -> Rc> { self.resolver() } + + fn demote<'d>(self) -> Demoted<'a, 'd, Ctx> + where + 'a: 'd, + Self: 'd, + { + Demoted(self) + } } diff --git a/src/rstd/inlining.rs b/src/rstd/inlining.rs index 69c269c..3be67cb 100644 --- a/src/rstd/inlining.rs +++ b/src/rstd/inlining.rs @@ -22,6 +22,8 @@ pub trait InCtxDyn<'a: 'c, 'c, Ctx: Context<'a>>: 'c { fn idnext_address(self) -> ResultDyn>>; fn idresolver(&self) -> Rc>; + + fn iddemote(self) -> Demoted<'a, 'c, Ctx>; } impl<'a: 'c, 'c, Ctx: Context<'a>, I: 'c + InCtx<'a, Ctx>> InCtxDyn<'a, 'c, Ctx> for I { @@ -46,6 +48,10 @@ impl<'a: 'c, 'c, Ctx: Context<'a>, I: 'c + InCtx<'a, Ctx>> InCtxDyn<'a, 'c, Ctx> fn idresolver(&self) -> Rc> { self.iresolver() } + + fn iddemote(self) -> Demoted<'a, 'c, Ctx> { + self.demote() + } } impl<'a: 'c, 'c, Ctx: Context<'a>> Inlining for Box> { @@ -76,6 +82,14 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for Box Rc> { self.idresolver() } + + fn demote<'d>(self) -> Demoted<'a, 'd, Ctx> + where + 'a: 'd, + Self: 'd, + { + self.iddemote() + } } pub type IParseResult<'a, Ctx, F, I> =