inlining dyn lifetimes

This commit is contained in:
AF 2023-06-30 21:45:28 +00:00
parent b5862b45fd
commit 6a4cb9504c

View File

@ -88,18 +88,18 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for &'c mut dyn DeCtx<'a, Ctx>
}
}
pub trait InliningDyn {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Box<Self>), Vec<u8>>;
pub trait InliningDyn<'c>: 'c {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Box<dyn InliningDyn<'c>>), Vec<u8>>;
fn idread_all(self) -> Vec<u8>;
fn idtell(&self) -> usize;
}
impl<I: Inlining> InliningDyn for I {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Box<Self>), Vec<u8>> {
impl<'c, I: 'c + Inlining> InliningDyn<'c> for I {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Box<dyn InliningDyn<'c>>), Vec<u8>> {
let (vec, i) = self.iread_n(n, |slice| Vec::from(slice), |slice| Vec::from(slice))?;
Ok((vec, i.into()))
Ok((vec, Box::new(i)))
}
fn idread_all(self) -> Vec<u8> {
@ -111,16 +111,16 @@ impl<I: Inlining> InliningDyn for I {
}
}
pub trait InCtxDyn<'a, Ctx: Context<'a>>: InliningDyn {
fn icdnext_address(self) -> Result<(Address, Box<Self>), Vec<u8>>;
pub trait InCtxDyn<'a: 'c, 'c, Ctx: Context<'a>>: InliningDyn<'c> {
fn icdnext_address(self) -> Result<(Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>), Vec<u8>>;
fn idresolver(&self) -> Rc<dyn Resolver<'a, Ctx>>;
}
impl<'a, Ctx: Context<'a>, I: InCtx<'a, Ctx>> InCtxDyn<'a, Ctx> for I {
fn icdnext_address(self) -> Result<(Address, Box<Self>), Vec<u8>> {
impl<'a: 'c, 'c, Ctx: Context<'a>, I: 'c + InCtx<'a, Ctx>> InCtxDyn<'a, 'c, Ctx> for I {
fn icdnext_address(self) -> Result<(Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>), Vec<u8>> {
let (address, i) = self.icnext_address(|slice| Vec::from(slice))?;
Ok((address, i.into()))
Ok((address, Box::new(i)))
}
fn idresolver(&self) -> Rc<dyn Resolver<'a, Ctx>> {