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 {
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 into(self) -> Box<dyn Parse> {
Box::new(self.0)
fn as_dyn(&self) -> &dyn Parse where Self: Sized {
self
}
}
pub trait AndThenParser<P> {
fn and_then(&mut self, parser: P) -> &Self;
impl<P: Parse + 'static> Into<Box<dyn Parse>> for (P,) {
fn into(self) -> Box<dyn Parse> {
Box::new(self.0)
}
}
pub struct Parser<'a> {