From 8121a30b0c306ac5e5b48dcee5ea0b7ec12003df Mon Sep 17 00:00:00 2001 From: KitsuneCafe <10284516+kitsunecafe@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:09:28 -0500 Subject: [PATCH] remove static lifetime requirement --- src/roxy.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/roxy.rs b/src/roxy.rs index 496d010..80dc942 100644 --- a/src/roxy.rs +++ b/src/roxy.rs @@ -12,21 +12,21 @@ pub trait AndThenParser

{ fn and_then(&mut self, parser: P) -> &Self; } -pub struct Parser { - steps: Vec>, +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(&mut self, parser: P) { - self.steps.push(Box::new(parser)); + pub fn push(&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) -> std::io::Result<()> { let mut buf_1 = Vec::from(src); let mut buf_2 = Vec::from(dst.as_slice());