Skip to main content

ident

Macro ident 

Source
macro_rules! ident {
    ($name:ident) => { ... };
}
Expand description

Build a syn::Ident from a bare identifier token. Unlike syn::parse_quote!, this always yields the concrete type syn::Ident — there’s no external context needed to infer it — so it can be passed directly into a generic impl Into<T> parameter without hitting rustc’s “type annotations needed” ambiguity. syn::parse_quote!’s output type has to be pinned by a concrete parameter type to infer successfully; a generic impl Into<T> bound doesn’t give it anything to unify against.

This is what powers the fun! decl macro — see that macro (and the prebindgen-jni crate’s ptr_class!/enum_class!/data_class!, which apply the same trick to syn::Type) for the primary way this crate’s builders are fed bare Rust names today.

let _: syn::Ident = prebindgen_registry::ident!(z_thing_name);