Open stefnotch opened 1 year ago
I don't think the code you've suggested would add any value in making sense of the API.
IMO it'd still be worthwhile to mention which functions the API actually provides, without having to search quite as much.
But yes, the example isn't that well chosen. Here'd be a possibly more useful example. (Untested though)
fn is_identifier(value: &str) {
let mut chars = value.chars();
chars.next().filter(|c| is_xid_start(*c)).is_some() && chars.all(|c| is_xid_continue(c))
}
is_identifier("cat1"); // returns true
is_identifier("42"); // returns false
Would it be possible to have a minimal example at the top of the readme that showcases the really sleek API? Something like
Also, thank you very much for all your awesome work on those lovely Rust projects!