Skip to content

Commit

Permalink
Merge pull request #675 from epage/cherry
Browse files Browse the repository at this point in the history
fix(comb): Deprecate top-level opaque impls
  • Loading branch information
epage authored Jan 6, 2025
2 parents e7c765f + 010d73e commit c20aba1
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 72 deletions.
44 changes: 23 additions & 21 deletions src/combinator/parser.rs → src/combinator/impls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Opaque implementations of [`Parser`]
use crate::combinator::trace;
use crate::combinator::trace_result;
use crate::combinator::DisplayDebug;
Expand All @@ -14,7 +16,7 @@ use crate::stream::StreamIsPartial;
use crate::stream::{Location, Stream};
use crate::*;

/// Implementation of [`Parser::by_ref`]
/// [`Parser`] implementation for [`Parser::by_ref`]
pub struct ByRef<'p, P> {
pub(crate) p: &'p mut P,
}
Expand All @@ -29,7 +31,7 @@ where
}
}

/// Implementation of [`Parser::map`]
/// [`Parser`] implementation for [`Parser::map`]
pub struct Map<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -57,7 +59,7 @@ where
}
}

/// Implementation of [`Parser::try_map`]
/// [`Parser`] implementation for [`Parser::try_map`]
pub struct TryMap<F, G, I, O, O2, E, E2>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -94,7 +96,7 @@ where
}
}

/// Implementation of [`Parser::verify_map`]
/// [`Parser`] implementation for [`Parser::verify_map`]
pub struct VerifyMap<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -130,7 +132,7 @@ where
}
}

/// Implementation of [`Parser::and_then`]
/// [`Parser`] implementation for [`Parser::and_then`]
pub struct AndThen<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -166,7 +168,7 @@ where
}
}

/// Implementation of [`Parser::parse_to`]
/// [`Parser`] implementation for [`Parser::parse_to`]
pub struct ParseTo<P, I, O, O2, E>
where
P: Parser<I, O, E>,
Expand Down Expand Up @@ -201,7 +203,7 @@ where
}
}

/// Implementation of [`Parser::flat_map`]
/// [`Parser`] implementation for [`Parser::flat_map`]
pub struct FlatMap<F, G, H, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -230,7 +232,7 @@ where
}
}

/// Implementation of [`Parser::complete_err`]
/// [`Parser`] implementation for [`Parser::complete_err`]
pub struct CompleteErr<F> {
pub(crate) f: F,
}
Expand All @@ -255,7 +257,7 @@ where
}
}

/// Implementation of [`Parser::verify`]
/// [`Parser`] implementation for [`Parser::verify`]
pub struct Verify<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -295,7 +297,7 @@ where
}
}

/// Implementation of [`Parser::value`]
/// [`Parser`] implementation for [`Parser::value`]
pub struct Value<F, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand All @@ -319,7 +321,7 @@ where
}
}

/// Implementation of [`Parser::default_value`]
/// [`Parser`] implementation for [`Parser::default_value`]
pub struct DefaultValue<F, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand All @@ -343,7 +345,7 @@ where
}
}

/// Implementation of [`Parser::void`]
/// [`Parser`] implementation for [`Parser::void`]
pub struct Void<F, I, O, E>
where
F: Parser<I, O, E>,
Expand All @@ -368,7 +370,7 @@ where
#[deprecated(since = "0.6.14", note = "Replaced with `Take`")]
pub type Recognize<F, I, O, E> = Take<F, I, O, E>;

/// Implementation of [`Parser::take`]
/// [`Parser`] implementation for [`Parser::take`]
pub struct Take<F, I, O, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -404,7 +406,7 @@ where
#[deprecated(since = "0.6.14", note = "Replaced with `WithTaken`")]
pub type WithRecognized<F, I, O, E> = WithTaken<F, I, O, E>;

/// Implementation of [`Parser::with_taken`]
/// [`Parser`] implementation for [`Parser::with_taken`]
pub struct WithTaken<F, I, O, E>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -436,7 +438,7 @@ where
}
}

/// Implementation of [`Parser::span`]
/// [`Parser`] implementation for [`Parser::span`]
pub struct Span<F, I, O, E>
where
F: Parser<I, O, E>,
Expand All @@ -463,7 +465,7 @@ where
}
}

/// Implementation of [`Parser::with_span`]
/// [`Parser`] implementation for [`Parser::with_span`]
pub struct WithSpan<F, I, O, E>
where
F: Parser<I, O, E>,
Expand All @@ -490,7 +492,7 @@ where
}
}

/// Implementation of [`Parser::output_into`]
/// [`Parser`] implementation for [`Parser::output_into`]
pub struct OutputInto<F, I, O, O2, E>
where
F: Parser<I, O, E>,
Expand All @@ -514,7 +516,7 @@ where
}
}

/// Implementation of [`Parser::err_into`]
/// [`Parser`] implementation for [`Parser::err_into`]
pub struct ErrInto<F, I, O, E, E2>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -543,7 +545,7 @@ where
}
}

/// Implementation of [`Parser::context`]
/// [`Parser`] implementation for [`Parser::context`]
pub struct Context<F, I, O, E, C>
where
F: Parser<I, O, E>,
Expand Down Expand Up @@ -578,7 +580,7 @@ where
}
}

/// Implementation of [`Parser::retry_after`]
/// [`Parser`] implementation for [`Parser::retry_after`]
#[cfg(feature = "unstable-recover")]
#[cfg(feature = "std")]
pub struct RetryAfter<P, R, I, O, E>
Expand Down Expand Up @@ -654,7 +656,7 @@ where
}
}

/// Implementation of [`Parser::resume_after`]
/// [`Parser`] implementation for [`Parser::resume_after`]
#[cfg(feature = "unstable-recover")]
#[cfg(feature = "std")]
pub struct ResumeAfter<P, R, I, O, E>
Expand Down
6 changes: 4 additions & 2 deletions src/combinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,19 @@ mod branch;
mod core;
mod debug;
mod multi;
mod parser;
mod sequence;

#[cfg(test)]
mod tests;

pub mod impls;

pub use self::branch::*;
pub use self::core::*;
pub use self::debug::*;
#[deprecated(since = "0.6.23", note = "Replaced with `combinator::impls`")]
pub use self::impls::*;
pub use self::multi::*;
pub use self::parser::*;
pub use self::sequence::*;

#[allow(unused_imports)]
Expand Down
2 changes: 1 addition & 1 deletion src/combinator/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
}
}

/// Implementation of [`repeat`]
/// Customizable [`Parser`] implementation for [`repeat`]
pub struct Repeat<P, I, O, C, E>
where
P: Parser<I, O, E>,
Expand Down
Loading

0 comments on commit c20aba1

Please sign in to comment.