-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from epage/docs
docs: Try to make people more successful with `cut_err`
- Loading branch information
Showing
20 changed files
with
95 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
//! # Custom Errors | ||
//! | ||
//! The most basic error type is [`ParserError`][crate::error::ParserError] | ||
//! Between [`ContextError`], [`Parser::context`], and [`cut_err`], | ||
//! most error needs will likely be met | ||
//! (see [tutorial][chapter_6]). | ||
//! When that isn't the case, you can implement your own error type. | ||
//! | ||
//! The most basic error trait is [`ParserError`]. | ||
//! | ||
//! Optional traits include: | ||
//! - [`AddContext`][crate::error::AddContext] | ||
//! - [`FromExternalError`][crate::error::FromExternalError] | ||
//! - [`AddContext`] | ||
//! - [`FromExternalError`] | ||
//! | ||
//! # Example | ||
//! | ||
//!```rust | ||
#![doc = include_str!("../../examples/custom_error.rs")] | ||
//!``` | ||
#![allow(unused_imports)] | ||
use crate::combinator::cut_err; | ||
use crate::error::ContextError; | ||
use crate::Parser; | ||
use crate::_tutorial::chapter_6; | ||
use crate::error::AddContext; | ||
use crate::error::FromExternalError; | ||
use crate::error::ParserError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`: | ||
//!  | ||
//! | ||
//! 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ pub mod chapter_4; | |
pub mod chapter_5; | ||
pub mod chapter_6; | ||
pub mod chapter_7; | ||
pub mod chapter_8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! Deprecated, replaced with [`winnow::combinator`][crate::combinator] | ||
/// Deprecated, replaced with [`winnow::combinator::trace`][crate::combinator::trace] | ||
#[deprecated(since = "0.5.35", note = "Replaced with `winnow::combinator::trace`")] | ||
#[inline(always)] | ||
pub fn trace<I: crate::stream::Stream, O, E>( | ||
name: impl crate::lib::std::fmt::Display, | ||
parser: impl crate::Parser<I, O, E>, | ||
) -> impl crate::Parser<I, O, E> { | ||
crate::combinator::trace(name, parser) | ||
} |