The documentation of Ident says: »A word of Rust code, which may be a keyword or legal variable name.« But parsing a keyword fails: println!("{:?}", syn::parse_str::<syn::Ident>("struct"));
How can I parse a word (keyword or variable name) with syn?
An identifier constructed with Ident::new is permitted to be a Rust keyword, though parsing one through its Parse implementation rejects Rust keywords. Use input.call(Ident::parse_any) when parsing to match the behaviour of Ident::new .