remove static lifetime requirement

This commit is contained in:
KitsuneCafe 2024-02-01 16:09:28 -05:00
parent 72d23383d6
commit 8121a30b0c
1 changed files with 6 additions and 6 deletions

View File

@ -12,21 +12,21 @@ pub trait AndThenParser<P> {
fn and_then(&mut self, parser: P) -> &Self;
}
pub struct Parser {
steps: Vec<Box<dyn Parse>>,
pub struct Parser<'a> {
steps: Vec<&'a mut dyn Parse>,
}
impl Parser {
impl<'a> Parser<'a> {
pub fn new() -> Self {
Parser { steps: Vec::new() }
}
pub fn push<P: Parse + 'static>(&mut self, parser: P) {
self.steps.push(Box::new(parser));
pub fn push<P: Parse>(&mut self, parser: &'a mut P) {
self.steps.push(parser);
}
}
impl Parse for Parser {
impl<'a> Parse for Parser<'a> {
fn parse(&mut self, path: &str, src: &[u8], dst: &mut Vec<u8>) -> std::io::Result<()> {
let mut buf_1 = Vec::from(src);
let mut buf_2 = Vec::from(dst.as_slice());