• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! # Chapter 8: Debugging
2 //!
3 //! When things inevitably go wrong, you can introspect the parsing state by running your test case
4 //! with `--features winnow/debug`:
5 //!
6 //! ![Trace output from string example](https://raw.githubusercontent.com/winnow-rs/winnow/main/assets/trace.svg "Example output")
7 //!
8 //! You can extend your own parsers to show up by wrapping their body with
9 //! [`trace`][crate::combinator::trace].  Going back to [`do_nothing_parser`][super::chapter_1].
10 //! ```rust
11 //! # use winnow::PResult;
12 //! # use winnow::Parser;
13 //! use winnow::combinator::trace;
14 //!
15 //! pub fn do_nothing_parser<'s>(input: &mut &'s str) -> PResult<&'s str> {
16 //!     trace(
17 //!         "do_nothing_parser",
18 //!         |i: &mut _| Ok("")
19 //!     ).parse_next(input)
20 //! }
21 //! #
22 //! # fn main() {
23 //! #     let mut input = "0x1a2b Hello";
24 //! #
25 //! #     let output = do_nothing_parser.parse_next(&mut input).unwrap();
26 //! #     // Same as:
27 //! #     // let output = do_nothing_parser(&mut input).unwrap();
28 //! #
29 //! #     assert_eq!(input, "0x1a2b Hello");
30 //! #     assert_eq!(output, "");
31 //! # }
32 //! ```
33 
34 pub use super::chapter_7 as previous;
35 pub use crate::_tutorial as table_of_contents;
36