aboutsummaryrefslogtreecommitdiff
path: root/src/naive_parser.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-12 07:13:58 +0200
committerMartin Fischer <martin@push-f.com>2023-09-28 10:36:08 +0200
commitc63b39bc78f1047b717d4c7b775047e86318d590 (patch)
tree2747ef4fb482627a414c793bdc3cdf49a6b09366 /src/naive_parser.rs
parent27e984084317ebbacdaf67823e4ee12a9060d76e (diff)
refactor: make NaiveParser new* signatures more readable
Diffstat (limited to 'src/naive_parser.rs')
-rw-r--r--src/naive_parser.rs27
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 }