kevinmehall / rust-peg

Parsing Expression Grammar (PEG) parser generator for Rust
https://crates.io/crates/peg
MIT License
1.44k stars 105 forks source link

Fix identifier example in top-level docs #330

Closed tchajed closed 1 year ago

tchajed commented 1 year ago

Formerly this example wouldn't parse single-letter identifiers, which might confuse someone using it directly.

If you'd like, another possible improvement is to make the doc test run and add the following to main:

fn main() {
    doc::identifier("a").expect("a");
    doc::identifier("foo1").expect("foo1");
    doc::identifier("1up").expect_err("starts with number");
    doc::identifier("hello there").expect_err("has a space");
}
kevinmehall commented 1 year ago

Good find, thanks!