From 0d01692c97ea8ca6fc4b229e5b9678cb252bceda Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Sat, 9 Jan 2021 14:31:02 +0000 Subject: Introduce chomp as a procedural macro. Add a bunch of tests. Fix chomp and chewed so autochomp compiles. --- chewed/src/parse.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'chewed/src') diff --git a/chewed/src/parse.rs b/chewed/src/parse.rs index 58bb94c..65e9272 100644 --- a/chewed/src/parse.rs +++ b/chewed/src/parse.rs @@ -21,7 +21,7 @@ pub trait Parser { P::parse(self) } - fn take_str(&mut self, s: &'static str) -> Result<(), TakeError> { + fn consume_str(&mut self, s: &'static str) -> Result<(), TakeError> { let mut count = 0; for exp in s.chars() { @@ -114,6 +114,14 @@ pub trait Parse: Sized { Ok(res) } } + + fn take_str(input: &str) -> Result { + Self::take(&mut IterWrapper::new(input.chars())) + } + + fn parse_str(input: &str) -> Result { + Self::parse(IterWrapper::new(input.chars())) + } } impl Parse for () { -- cgit v1.2.3