diff options
Diffstat (limited to 'vendor/winnow/src/_tutorial/chapter_4.rs')
-rw-r--r-- | vendor/winnow/src/_tutorial/chapter_4.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/vendor/winnow/src/_tutorial/chapter_4.rs b/vendor/winnow/src/_tutorial/chapter_4.rs index 5d19a05bc..315d185ba 100644 --- a/vendor/winnow/src/_tutorial/chapter_4.rs +++ b/vendor/winnow/src/_tutorial/chapter_4.rs @@ -22,7 +22,7 @@ //! ```rust //! # use winnow::Parser; //! # use winnow::IResult; -//! # use winnow::character::digit1; +//! # use winnow::ascii::digit1; //! # //! fn parse_digits(input: &str) -> IResult<&str, usize> { //! digit1 @@ -41,47 +41,47 @@ //! } //! ``` //! -//! `Parser::parse_to` is just a convenient form of [`Parser::map_res`] which we can use to handle +//! `Parser::parse_to` is just a convenient form of [`Parser::try_map`] which we can use to handle //! all radices of numbers: //! ```rust //! # use winnow::IResult; //! # use winnow::Parser; -//! # use winnow::bytes::take_while1; -//! use winnow::branch::dispatch; -//! use winnow::bytes::take; +//! # use winnow::token::take_while; +//! use winnow::combinator::dispatch; +//! use winnow::token::take; //! use winnow::combinator::fail; //! //! fn parse_digits(input: &str) -> IResult<&str, usize> { //! dispatch!(take(2usize); -//! "0b" => parse_bin_digits.map_res(|s| usize::from_str_radix(s, 2)), -//! "0o" => parse_oct_digits.map_res(|s| usize::from_str_radix(s, 8)), -//! "0d" => parse_dec_digits.map_res(|s| usize::from_str_radix(s, 10)), -//! "0x" => parse_hex_digits.map_res(|s| usize::from_str_radix(s, 16)), +//! "0b" => parse_bin_digits.try_map(|s| usize::from_str_radix(s, 2)), +//! "0o" => parse_oct_digits.try_map(|s| usize::from_str_radix(s, 8)), +//! "0d" => parse_dec_digits.try_map(|s| usize::from_str_radix(s, 10)), +//! "0x" => parse_hex_digits.try_map(|s| usize::from_str_radix(s, 16)), //! _ => fail, //! ).parse_next(input) //! } //! //! // ... //! # fn parse_bin_digits(input: &str) -> IResult<&str, &str> { -//! # take_while1(( +//! # take_while(1.., ( //! # ('0'..='7'), //! # )).parse_next(input) //! # } //! # //! # fn parse_oct_digits(input: &str) -> IResult<&str, &str> { -//! # take_while1(( +//! # take_while(1.., ( //! # ('0'..='7'), //! # )).parse_next(input) //! # } //! # //! # fn parse_dec_digits(input: &str) -> IResult<&str, &str> { -//! # take_while1(( +//! # take_while(1.., ( //! # ('0'..='9'), //! # )).parse_next(input) //! # } //! # //! # fn parse_hex_digits(input: &str) -> IResult<&str, &str> { -//! # take_while1(( +//! # take_while(1.., ( //! # ('0'..='9'), //! # ('A'..='F'), //! # ('a'..='f'), |