Comments.

Coverage to Makefile.toml.

Added branch to map! to allow for instantiating with default values.
This commit is contained in:
Martin Berg Alstad
2024-08-31 17:49:27 +02:00
parent 8fb89e0459
commit 7e2df67fee
10 changed files with 95 additions and 4 deletions

View File

@ -47,6 +47,29 @@ where
take_while_m_n(n, n, predicate)
}
/// Parse the inner parser and then the end of the input.
/// Very useful for ensuring that the entire input is consumed.
/// - Parameters
/// - `inner`: The parser to run
/// - Returns: A parser that runs the inner parser and then the end of the input
/// # Example
/// ```
/// use nom::bytes::complete::{tag};
/// use lib::nom::combinators::exhausted;
///
/// let input = "test";
/// let (remaining, result) = exhausted(tag("test"))(input).unwrap();
/// assert_eq!(remaining, "");
/// assert_eq!(result, "test");
/// ```
/// - Fails if the input is not exhausted
/// ```
/// use nom::bytes::complete::{tag};
/// use lib::nom::combinators::exhausted;
///
/// let input = "test";
/// assert!(exhausted(tag("tes"))(input).is_err());
/// ```
pub fn exhausted<'a, Parser, R>(inner: Parser) -> impl FnMut(&'a str) -> IResult<&'a str, R>
where
Parser: FnMut(&'a str) -> IResult<&'a str, R>,