gtk3_macros/util.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use proc_macro_crate::crate_name;
4use proc_macro2::{Ident, Span};
5
6pub fn crate_ident_new() -> Ident {
7 use proc_macro_crate::FoundCrate;
8
9 let crate_name = match crate_name("gtk").expect("missing gtk dependency in `Cargo.toml`") {
10 FoundCrate::Name(name) => name,
11 FoundCrate::Itself => "gtk".to_owned(),
12 };
13
14 Ident::new(&crate_name, Span::call_site())
15}