diff options
Diffstat (limited to 'vendor/toml_edit/src/parser/trivia.rs')
-rw-r--r-- | vendor/toml_edit/src/parser/trivia.rs | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/vendor/toml_edit/src/parser/trivia.rs b/vendor/toml_edit/src/parser/trivia.rs index 97ff49c73..ba47dcde6 100644 --- a/vendor/toml_edit/src/parser/trivia.rs +++ b/vendor/toml_edit/src/parser/trivia.rs @@ -1,15 +1,13 @@ use std::ops::RangeInclusive; -use winnow::branch::alt; -use winnow::bytes::one_of; -use winnow::bytes::take_while0; -use winnow::bytes::take_while1; +use winnow::combinator::alt; use winnow::combinator::eof; use winnow::combinator::opt; -use winnow::multi::many0; -use winnow::multi::many1; +use winnow::combinator::repeat; +use winnow::combinator::terminated; use winnow::prelude::*; -use winnow::sequence::terminated; +use winnow::token::one_of; +use winnow::token::take_while; use crate::parser::prelude::*; @@ -31,7 +29,7 @@ pub(crate) const WSCHAR: (u8, u8) = (b' ', b'\t'); // ws = *wschar pub(crate) fn ws(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { - take_while0(WSCHAR) + take_while(0.., WSCHAR) .map(|b| unsafe { from_utf8_unchecked(b, "`is_wschar` filters out on-ASCII") }) .parse_next(input) } @@ -51,7 +49,7 @@ pub(crate) const COMMENT_START_SYMBOL: u8 = b'#'; // comment = comment-start-symbol *non-eol pub(crate) fn comment(input: Input<'_>) -> IResult<Input<'_>, &[u8], ParserError<'_>> { - (COMMENT_START_SYMBOL, take_while0(NON_EOL)) + (COMMENT_START_SYMBOL, take_while(0.., NON_EOL)) .recognize() .parse_next(input) } @@ -70,13 +68,14 @@ pub(crate) const CR: u8 = b'\r'; // ws-newline = *( wschar / newline ) pub(crate) fn ws_newline(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { - many0(alt((newline.value(&b"\n"[..]), take_while1(WSCHAR)))) - .map(|()| ()) - .recognize() - .map(|b| unsafe { - from_utf8_unchecked(b, "`is_wschar` and `newline` filters out on-ASCII") - }) - .parse_next(input) + repeat( + 0.., + alt((newline.value(&b"\n"[..]), take_while(1.., WSCHAR))), + ) + .map(|()| ()) + .recognize() + .map(|b| unsafe { from_utf8_unchecked(b, "`is_wschar` and `newline` filters out on-ASCII") }) + .parse_next(input) } // ws-newlines = newline *( wschar / newline ) @@ -92,10 +91,17 @@ pub(crate) fn ws_newlines(input: Input<'_>) -> IResult<Input<'_>, &str, ParserEr // note: this rule is not present in the original grammar // ws-comment-newline = *( ws-newline-nonempty / comment ) pub(crate) fn ws_comment_newline(input: Input<'_>) -> IResult<Input<'_>, &[u8], ParserError<'_>> { - many0(alt(( - many1(alt((take_while1(WSCHAR), newline.value(&b"\n"[..])))).map(|()| ()), - comment.value(()), - ))) + repeat( + 0.., + alt(( + repeat( + 1.., + alt((take_while(1.., WSCHAR), newline.value(&b"\n"[..]))), + ) + .map(|()| ()), + comment.value(()), + )), + ) .map(|()| ()) .recognize() .parse_next(input) |