-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some holes in documentation #720
base: main
Are you sure you want to change the base?
Conversation
/// let list = letter | ||
/// .repeated() | ||
/// .to_slice() | ||
/// .map(|string: &str| string.chars()) | ||
/// .into_iter() | ||
/// .collect_exactly::<[char; 4]>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is a somewhat contrived example since the code could be expressed equivalently but more simply like so:
let list = letter.repeated().collect_exactly::<[char; 4]>();
A better example might be something like:
// Parses whole integers
let num = text::int().padded().map(|x| x.parse::<u64>().unwrap());
// Parses a range like `0..4` into a vector like `[0, 1, 2, 3]`
let range = num.ignore_then(just("..")).then(num)
.map(|(x, y)| x..y)
.into_iter()
.collect::<Vec<_>>();
// Parses a list of numbers into a vector
let list = num.separated_by(just(',')).collect::<Vec<_>>();
let set = range.or(list);
assert_eq!(set.parse("0, 1, 2, 3").unwrap(), [0, 1, 2, 3]);
assert_eq!(set.parse("0..4").unwrap(), [0, 1, 2, 3]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I think these changes are great. I've just one suggestion regarding one of the examples.
Hello!
Added some missing documentation, mostly examples and filling in holes in the error module.
Change list:
Let me know if I should make any changes