InCtx::demote

This commit is contained in:
AF 2023-07-01 14:20:23 +00:00
parent 0edcafad2a
commit 62b631d33d
2 changed files with 27 additions and 0 deletions

View File

@ -20,6 +20,11 @@ pub trait InCtx<'a, Ctx: Context<'a>>: Inlining {
/// Clone the reference to the current [Resolver].
fn iresolver(&self) -> Rc<dyn Resolver<'a, Ctx>>;
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<dyn Resolver<'a, Ctx>> {
self.resolver()
}
fn demote<'d>(self) -> Demoted<'a, 'd, Ctx>
where
'a: 'd,
Self: 'd,
{
Demoted(self)
}
}

View File

@ -22,6 +22,8 @@ pub trait InCtxDyn<'a: 'c, 'c, Ctx: Context<'a>>: 'c {
fn idnext_address(self) -> ResultDyn<Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>>;
fn idresolver(&self) -> Rc<dyn Resolver<'a, Ctx>>;
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<dyn Resolver<'a, Ctx>> {
self.iresolver()
}
fn iddemote(self) -> Demoted<'a, 'c, Ctx> {
self.demote()
}
}
impl<'a: 'c, 'c, Ctx: Context<'a>> Inlining for Box<dyn InCtxDyn<'a, 'c, Ctx>> {
@ -76,6 +82,14 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for Box<dyn InCtxDyn<'a, 'c, C
fn iresolver(&self) -> Rc<dyn Resolver<'a, Ctx>> {
self.idresolver()
}
fn demote<'d>(self) -> Demoted<'a, 'd, Ctx>
where
'a: 'd,
Self: 'd,
{
self.iddemote()
}
}
pub type IParseResult<'a, Ctx, F, I> =