Repository: Marwes/combine (language: rust)

Issue:
Documentation request: no_partial
It'd be very sweet if https://docs.rs/combine/4.6.6/combine/parser/combinator/fn.no_partial.html had a quick line explaining what it does. Or even just a link to a documentation section where it explains partial parsing.


Discussion / hints:

Fix patch:
diff --git a/src/parser/combinator.rs b/src/parser/combinator.rs
index e7a7ba19..97bae9a2 100644
--- a/src/parser/combinator.rs
+++ b/src/parser/combinator.rs
@@ -664,6 +664,30 @@ where
     forward_parser!(Input, add_error add_committed_expected_error parser_count, 0);
 }
 
+/// Wraps a parser `p` and disables partial parsing for it (changing the `PartialState` to `()`)
+///
+/// Partial parsing lets a parser accept incomplete (partial) input resume parsing when more input is available without re-parsing any part of the input.
+/// By disabling partial parsing for a parser it will need to restart its parse from the beginning once more input is available (no_partial ONLY affects the wrapped parser,
+/// any parsers calling the `no_partial` parser will still employ partial parsing).
+///
+/// If you are not using partial parsing this has no effect (except changing the typing of the parser).
+///
+/// ```
+/// # #[macro_use]
+/// # extern crate combine;
+/// # use combine::parser::combinator::no_partial;
+/// # use combine::parser::char::letter;
+/// # use combine::*;
+///
+/// # fn main() {
+///
+/// assert_eq!(
+///     (no_partial(letter()), letter()).easy_parse("ab"),
+///     Ok((('a', 'b'), ""))
+/// );
+///
+/// # }
+/// ```
 pub fn no_partial<Input, P>(p: P) -> NoPartial<P>
 where
     Input: Stream,
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 17a88b7d..24e880b7 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -842,6 +842,8 @@ pub trait Parser<Input: Stream> {
     ///     -> Box<dyn Parser<&'input str, Output = (char, char), PartialState = ()> + 'input>
     ///     where F: FnMut(char) -> bool + 'static
     /// {
+    ///     // Using no_partial here we do not need to name the type of `PartialState`
+    ///     // (though it disables partial parsing, if partial parsing is used `any_partial_state` can be used instead)
     ///     combine::parser::combinator::no_partial((token(c), satisfy(f))).boxed()
     /// }
     /// let result = test('a', |c| c >= 'a' && c <= 'f')


Test patch: