Parse::as_dyn

This commit is contained in:
KitsuneCafe 2024-02-05 03:06:23 -05:00
parent 4d50a1d287
commit 36530dc69a

View file

@ -8,16 +8,16 @@ use crate::error::Error;
pub trait Parse { pub trait Parse {
fn parse(&mut self, path: &str, src: &[u8], dst: &mut Vec<u8>) -> Result<(), Error>; fn parse(&mut self, path: &str, src: &[u8], dst: &mut Vec<u8>) -> Result<(), Error>;
}
impl<'a, P: Parse + 'static> Into<Box<dyn Parse>> for (P,) { fn as_dyn(&self) -> &dyn Parse where Self: Sized {
fn into(self) -> Box<dyn Parse> { self
Box::new(self.0)
} }
} }
pub trait AndThenParser<P> { impl<P: Parse + 'static> Into<Box<dyn Parse>> for (P,) {
fn and_then(&mut self, parser: P) -> &Self; fn into(self) -> Box<dyn Parse> {
Box::new(self.0)
}
} }
pub struct Parser<'a> { pub struct Parser<'a> {