Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add documentation to no_partial #363

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/parser/combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down