diff --git a/src/lib.rs b/src/lib.rs index 2a8cfdc..602ce57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,27 @@ trait Parser { fn parse(&self, input: I) -> ParseResult; } +struct BoxedParser { + inner: Box>, +} + +impl BoxedParser { + fn new

(inner: P) -> Self + where + P: Parser + 'static, + { + BoxedParser { + inner: Box::new(inner), + } + } +} + +impl Parser for BoxedParser { + fn parse(&self, input: I) -> ParseResult { + self.inner.parse(input) + } +} + impl Parser for F where F: Fn(I) -> ParseResult,