summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-10-24 01:44:12 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-10-24 01:44:12 -0400
commitf7914391a30921ab994ec1baf0d74a8f00972fd8 (patch)
tree6cb97b39160f54ce70deabc05d55c3c9b94c424c
parentdb6663437ca8cdf1612758f051311170ff421fdd (diff)
downloadmon-f7914391a30921ab994ec1baf0d74a8f00972fd8.tar.gz
change Parser::run reciever to &self
-rw-r--r--src/lib.rs54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 52fd55f..1f5a276 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -54,23 +54,23 @@ pub trait Parser<I: Input>: Sized {
type Output;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM>;
- fn parse(&mut self, it: InputIter<I>) -> ParserResult<I, Self::Output> {
+ fn parse(&self, it: InputIter<I>) -> ParserResult<I, Self::Output> {
self.run::<Emit, Emit, ()>(it)
}
- fn check(&mut self, it: InputIter<I>) -> ParserResult<I, Self::Output, Check, Emit> {
+ fn check(&self, it: InputIter<I>) -> ParserResult<I, Self::Output, Check, Emit> {
self.run::<Check, Emit, ()>(it)
}
- fn trace<T: Trace<I>>(&mut self, it: InputIter<I>) -> ParserResult<I, Self::Output> {
+ fn trace<T: Trace<I>>(&self, it: InputIter<I>) -> ParserResult<I, Self::Output> {
self.run::<Emit, Emit, T>(it)
}
- fn parse_finished(&mut self, it: InputIter<I>) -> Result<Self::Output, ParserFinishedError<I>> {
+ fn parse_finished(&self, it: InputIter<I>) -> Result<Self::Output, ParserFinishedError<I>> {
match self.parse(it) {
Ok((rest, output)) if rest.is_finished() => Ok(output),
Ok((rest, _)) => Err(ParserFinishedError::Unfinished(rest)),
@@ -78,7 +78,7 @@ pub trait Parser<I: Input>: Sized {
}
}
- fn check_finished(&mut self, it: InputIter<I>) -> Result<(), ParserFinishedError<I>> {
+ fn check_finished(&self, it: InputIter<I>) -> Result<(), ParserFinishedError<I>> {
match self.parse(it) {
Ok((rest, _)) if rest.is_finished() => Ok(()),
Ok((rest, _)) => Err(ParserFinishedError::Unfinished(rest)),
@@ -194,7 +194,7 @@ where
type Output = O;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("fn", it.clone());
@@ -220,7 +220,7 @@ where
type Output = O;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
match self.parser.run::<OM, EM, Tracer>(it) {
@@ -244,7 +244,7 @@ where
type Output = (P1::Output, P2::Output);
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("and", it.clone());
@@ -277,7 +277,7 @@ where
type Output = P1::Output;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("andnot", it.clone());
@@ -305,7 +305,7 @@ where
type Output = O;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("or", it.clone());
@@ -333,7 +333,7 @@ where
type Output = I;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("take", it.clone());
@@ -373,7 +373,7 @@ where
type Output = I;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("takewhile", it.clone());
@@ -411,7 +411,7 @@ where
type Output = I;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("takewhile1", it.clone());
@@ -454,7 +454,7 @@ where
type Output = I::Item;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("oneof", it.clone());
@@ -491,7 +491,7 @@ where
type Output = I::Item;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("if", it.clone());
@@ -525,7 +525,7 @@ where
type Output = P1::Output;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("preceded by", it.clone());
@@ -553,7 +553,7 @@ where
type Output = P1::Output;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("followed by", it.clone());
@@ -587,7 +587,7 @@ where
type Output = P1::Output;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("delimited by", it.clone());
@@ -622,7 +622,7 @@ where
type Output = I;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("recognize", it.clone());
@@ -651,7 +651,7 @@ where
type Output = I;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("tag", it.clone());
@@ -686,7 +686,7 @@ where
type Output = Vec<P1::Output>;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("separated list", it.clone());
@@ -729,7 +729,7 @@ where
type Output = Vec<P1::Output>;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
mut it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
Tracer::trace("separated list 1", it.clone());
@@ -778,7 +778,7 @@ where
type Output = ();
fn run<OM: Mode, EM: Mode, T: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
match self.parser.check(it.clone()) {
@@ -808,7 +808,7 @@ where
type Output = Option<P::Output>;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
match self.parser.run::<OM, EM, Tracer>(it.clone()) {
@@ -840,7 +840,7 @@ where
type Output = P::Output;
fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
match self.parser.run::<Emit, Emit, Tracer>(it.clone()) {
@@ -865,7 +865,7 @@ where
type Output = ();
fn run<OM: Mode, EM: Mode, T: Trace<I>>(
- &mut self,
+ &self,
it: InputIter<I>,
) -> ParserResult<I, Self::Output, OM, EM> {
match self.parser.check(it) {