In a procedural macro, I wish to be able to check a string is a valid variable name and is not a keyword.
proc_macro2::Ident
will panic if one tries to use an invalid variable name, but it will allow keywords which I do not want to be allowed. It would also be nicer to handle the error with a nice and useful error message before panicking.
Is there some macro or function (in a crate or otherwise) that will check a string obeys the rules about variable names? I could probably do it with a regex, but dragons live in regexes.
The use case for this is in handling user input strings, which may include garbage strings.