gtk4_macros/util.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use proc_macro2::{Ident, Span};
4use proc_macro_crate::crate_name;
5
6pub fn crate_ident_new() -> Ident {
7 use proc_macro_crate::FoundCrate;
8
9 // Use crate name detected from Cargo.toml or "gtk" for use in re-exports
10 let crate_name = match crate_name("gtk4") {
11 Ok(FoundCrate::Name(name)) => name,
12 Ok(FoundCrate::Itself) => "gtk4".to_owned(),
13 Err(_) => "gtk".to_owned(),
14 };
15
16 Ident::new(&crate_name, Span::call_site())
17}