Skip to content

Commit

Permalink
Merge pull request #673 from epage/impls
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 ed0f2a2 + 95bb79b commit 2b840ca
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, I, O, E> {
pub(crate) p: &'p mut P,
pub(crate) i: core::marker::PhantomData<I>,
Expand All @@ -32,7 +34,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 @@ -60,7 +62,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 @@ -97,7 +99,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 @@ -133,7 +135,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 @@ -169,7 +171,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 @@ -204,7 +206,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 @@ -233,7 +235,7 @@ where
}
}

/// Implementation of [`Parser::complete_err`]
/// [`Parser`] implementation for [`Parser::complete_err`]
pub struct CompleteErr<P, I, O, E> {
pub(crate) p: P,
pub(crate) i: core::marker::PhantomData<I>,
Expand Down Expand Up @@ -261,7 +263,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 @@ -301,7 +303,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 @@ -325,7 +327,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 @@ -349,7 +351,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 @@ -374,7 +376,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 @@ -410,7 +412,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 @@ -442,7 +444,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 @@ -469,7 +471,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 @@ -496,7 +498,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 @@ -520,7 +522,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 @@ -549,7 +551,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 @@ -584,7 +586,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 @@ -660,7 +662,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 2b840ca

Please sign in to comment.