diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2024-02-07 09:30:05 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-02-07 09:30:05 +0000 |
commit | 7a8da45bafcdc38a30874bd837fa06d6762c8ff9 (patch) | |
tree | 919294d605d7361ac40c3deea144cdbcc5b9e114 /src/_tutorial/chapter_8.rs | |
parent | 6453acf0b3d479544a778dfa6220650c4ea21922 (diff) | |
parent | 0c65325da3ac3393f0f225cb4d19c3f289fa3519 (diff) | |
download | winnow-7a8da45bafcdc38a30874bd837fa06d6762c8ff9.tar.gz |
Upgrade winnow to 0.5.37 am: 0c65325da3
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/winnow/+/2950810
Change-Id: I55145a8a10e0ab9f1b818f711d277ec97f02fb8f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/_tutorial/chapter_8.rs')
-rw-r--r-- | src/_tutorial/chapter_8.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/_tutorial/chapter_8.rs b/src/_tutorial/chapter_8.rs new file mode 100644 index 0000000..6ff8f29 --- /dev/null +++ b/src/_tutorial/chapter_8.rs @@ -0,0 +1,34 @@ +//! # Chapter 8: Debugging +//! +//! When things inevitably go wrong, you can introspect the parsing state by running your test case +//! with `--features debug`: +//! ![Trace output from string example](https://raw.githubusercontent.com/winnow-rs/winnow/main/assets/trace.svg "Example output") +//! +//! You can extend your own parsers to show up by wrapping their body with +//! [`trace`][crate::combinator::trace]. Going back to [`do_nothing_parser`][super::chapter_1]. +//! ```rust +//! # use winnow::PResult; +//! # use winnow::Parser; +//! use winnow::combinator::trace; +//! +//! pub fn do_nothing_parser<'s>(input: &mut &'s str) -> PResult<&'s str> { +//! trace( +//! "do_nothing_parser", +//! |i: &mut _| Ok("") +//! ).parse_next(input) +//! } +//! # +//! # fn main() { +//! # let mut input = "0x1a2b Hello"; +//! # +//! # let output = do_nothing_parser.parse_next(&mut input).unwrap(); +//! # // Same as: +//! # // let output = do_nothing_parser(&mut input).unwrap(); +//! # +//! # assert_eq!(input, "0x1a2b Hello"); +//! # assert_eq!(output, ""); +//! # } +//! ``` + +pub use super::chapter_7 as previous; +pub use crate::_tutorial as table_of_contents; |