diff options
Diffstat (limited to 'src/naive_parser.rs')
-rw-r--r-- | src/naive_parser.rs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/naive_parser.rs b/src/naive_parser.rs index ac82d46..4988477 100644 --- a/src/naive_parser.rs +++ b/src/naive_parser.rs @@ -30,20 +30,33 @@ pub struct NaiveParser<R: Reader, O: Offset, E: Emitter<O>> { tokenizer: Tokenizer<R, O, E>, } -impl<R: Reader + Position<O>, O: Offset> NaiveParser<R, O, DefaultEmitter<O>> { +impl<R, O> NaiveParser<R, O, DefaultEmitter<O>> +where + R: Reader + Position<O>, + O: Offset, +{ /// Constructs a new naive parser. // TODO: add example for NaiveParser::new - pub fn new<'a>(reader: impl IntoReader<'a, Reader = R>) -> Self { - let mut tokenizer = Tokenizer::new(reader, DefaultEmitter::default()); - tokenizer.enable_naive_state_switching(); - NaiveParser { tokenizer } + pub fn new<'a, IR>(reader: IR) -> NaiveParser<R, O, DefaultEmitter<O>> + where + IR: IntoReader<'a, Reader = R>, + { + NaiveParser::new_with_emitter(reader, DefaultEmitter::default()) } } -impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> NaiveParser<R, O, E> { +impl<R, O, E> NaiveParser<R, O, E> +where + R: Reader + Position<O>, + O: Offset, + E: Emitter<O>, +{ /// Constructs a new naive parser with a custom emitter. // TODO: add example for NaiveParser::new_with_emitter - pub fn new_with_emitter<'a>(reader: impl IntoReader<'a, Reader = R>, emitter: E) -> Self { + pub fn new_with_emitter<'a, IR>(reader: IR, emitter: E) -> NaiveParser<R, O, E> + where + IR: IntoReader<'a, Reader = R>, + { let mut tokenizer = Tokenizer::new(reader, emitter); tokenizer.enable_naive_state_switching(); NaiveParser { tokenizer } |