diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-01-09 14:31:02 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-01-09 14:31:02 +0000 |
commit | 0d01692c97ea8ca6fc4b229e5b9678cb252bceda (patch) | |
tree | 6c5ed07740b814f50dddbc6afaefc21c11dc3440 /chewed/src | |
parent | 487ce4fe0fa081f58d790d7d6417bf7d2659197c (diff) |
Introduce chomp as a procedural macro.
Add a bunch of tests.
Fix chomp and chewed so autochomp compiles.
Diffstat (limited to 'chewed/src')
-rw-r--r-- | chewed/src/parse.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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, TakeError> { + Self::take(&mut IterWrapper::new(input.chars())) + } + + fn parse_str(input: &str) -> Result<Self, ParseError> { + Self::parse(IterWrapper::new(input.chars())) + } } impl Parse for () { |