InliningDyn

This commit is contained in:
AF 2023-06-30 21:27:31 +00:00
parent ca48aba4fb
commit 8cf8680353

View File

@ -88,6 +88,28 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for &'c mut dyn DeCtx<'a, Ctx>
} }
} }
pub trait InliningDyn: Sized {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Self), 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>, Self), Vec<u8>> {
self.iread_n(n, |slice| Vec::from(slice), |slice| Vec::from(slice))
}
fn idread_all(self) -> Vec<u8> {
self.iread_all(|slice| Vec::from(slice))
}
fn idtell(&self) -> usize {
self.itell()
}
}
pub type IParseResult<'a, Ctx, F, I> = pub type IParseResult<'a, Ctx, F, I> =
Result<(Mtbl<'a, Ctx, F>, I), <F as Factory<'a, Ctx>>::ParseError>; Result<(Mtbl<'a, Ctx, F>, I), <F as Factory<'a, Ctx>>::ParseError>;