Return a result on `Ident::new` instead of panicking
- Dominant language
- Rust
- Stars
- 934
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Description
I am working on generating code for the wayland protocol in [waybackend](https://codeberg.org/LGFae/waybackend). When creating identifiers, some of them are invalid identifiers in Rust (an enum variant that is just a number). For those, I have been using the following fallback:
```Rust
// prepend an '_' if `name` is an invalid identifier
syn::parse_str(name).unwrap_or_else(|_| syn::parse_str(&format!("_{name}")).unwrap())
```
This is the only use of `syn` in `waybackend-scanner`. If `proc_macro2` returned a Result instead of panicking outright, I could have one less dependency in my project.
I believe this could also be done for some other types as well.
Of course, this would be a breaking change, since old code would break, though you could restore the old behavior by just calling `unwrap`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.