Skip to content

Commit

Permalink
docs: Deliver the promised line and column in the error of the first …
Browse files Browse the repository at this point in the history
…example
  • Loading branch information
Marwes committed Oct 22, 2016
1 parent c60ccbd commit efa2eb1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
//!
//! ```rust
//! extern crate combine;
//! use combine::Parser;
//! use combine::{Parser, State};
//! use combine::char::{digit, letter};
//! const MSG: &'static str = r#"Parse error at line: 1, column: 1
//! Unexpected '|'
//! Expected 'digit' or 'letter'"#;
//!
//! fn main() {
//! if let Err(err) = digit().or(letter()).parse("|") {
//! println!("{}", err);
//! // The println! call above prints
//! //
//! // Parse error at line: 1, column: 1
//! // Unexpected '|'
//! // Expected 'digit' or 'letter'
//! // Wrapping a `&str` with `State` provides automatic line and column tracking
//! if let Err(err) = digit().or(letter()).parse(State::new("|")) {
//! assert_eq!(MSG, format!("{}", MSG));
//! }
//! }
//! ```
Expand Down

0 comments on commit efa2eb1

Please sign in to comment.