Parse::as_dyn
This commit is contained in:
parent
4d50a1d287
commit
36530dc69a
10
src/roxy.rs
10
src/roxy.rs
|
@ -8,18 +8,18 @@ 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>;
|
||||||
|
|
||||||
|
fn as_dyn(&self) -> &dyn Parse where Self: Sized {
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, P: Parse + 'static> Into<Box<dyn Parse>> for (P,) {
|
impl<P: Parse + 'static> Into<Box<dyn Parse>> for (P,) {
|
||||||
fn into(self) -> Box<dyn Parse> {
|
fn into(self) -> Box<dyn Parse> {
|
||||||
Box::new(self.0)
|
Box::new(self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AndThenParser<P> {
|
|
||||||
fn and_then(&mut self, parser: P) -> &Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Parser<'a> {
|
pub struct Parser<'a> {
|
||||||
steps: Vec<&'a mut dyn Parse>,
|
steps: Vec<&'a mut dyn Parse>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue