From ca48aba4fbe6f4b22b58b65dec721888dd295ee1 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 30 Jun 2023 21:17:52 +0000 Subject: [PATCH] remove `InCtxT` --- src/rstd/inlining.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/rstd/inlining.rs b/src/rstd/inlining.rs index 62362c3..04b4f3e 100644 --- a/src/rstd/inlining.rs +++ b/src/rstd/inlining.rs @@ -52,35 +52,31 @@ pub trait InCtx<'a, Ctx: Context<'a>>: Inlining { fn iresolver(&self) -> Rc>; } -struct InCtxT<'a: 'c, 'c, Ctx: Context<'a>> { - dectx: &'c mut dyn DeCtx<'a, Ctx>, -} - -impl<'a: 'c, 'c, Ctx: Context<'a>> Inlining for InCtxT<'a, 'c, Ctx> { +impl<'a: 'c, 'c, Ctx: Context<'a>> Inlining for &'c mut dyn DeCtx<'a, Ctx> { fn iread_n( self, n: usize, ok: impl FnOnce(&[u8]) -> A, err: impl FnOnce(&[u8]) -> E, ) -> Result<(A, Self), E> { - match self.dectx.deserializer().iread_n(n, ok, err) { + match self.deserializer().iread_n(n, ok, err) { Ok((a, _)) => Ok((a, self)), Err(e) => Err(e), } } fn iread_all(self, ok: impl FnOnce(&[u8]) -> A) -> A { - self.dectx.deserializer().iread_all(ok) + self.deserializer().iread_all(ok) } fn itell(&self) -> usize { - self.dectx.tell() + self.tell() } } -impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for InCtxT<'a, 'c, Ctx> { +impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for &'c mut dyn DeCtx<'a, Ctx> { fn icnext_address(self, err: impl FnOnce(&[u8]) -> E) -> Result<(Address, Self), E> { - let (addresses, deserialiser, _) = self.dectx.adr(); + let (addresses, deserialiser, _) = self.adr(); match deserialiser.inext_address(addresses, err) { Ok((address, _)) => Ok((address, self)), Err(e) => Err(e), @@ -88,7 +84,7 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for InCtxT<'a, 'c, Ctx> { } fn iresolver(&self) -> Rc> { - self.dectx.resolver() + self.resolver() } }