| 1 |
use syn::parse_quote; |
| 2 |
|
| 3 |
pub fn crate_name() -> syn::Path { |
| 4 |
cfg_if::cfg_if! { |
| 5 |
if #[cfg(feature = "crate-name")] { |
| 6 |
use proc_macro_crate::FoundCrate; |
| 7 |
use quote::format_ident; |
| 8 |
|
| 9 |
match proc_macro_crate::crate_name("rstest").expect("rstest is present in `Cargo.toml` qed") |
| 10 |
{ |
| 11 |
FoundCrate::Itself => parse_quote! { rstest }, |
| 12 |
FoundCrate::Name(name) => { |
| 13 |
let myself = format_ident!("{name}"); |
| 14 |
parse_quote! { #myself } |
| 15 |
} |
| 16 |
} |
| 17 |
} else { |
| 18 |
parse_quote! { rstest } |
| 19 |
} |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
pub fn std_path() -> syn::Path { |
| 24 |
let rstest = crate_name(); |
| 25 |
parse_quote! { #rstest::__std } |
| 26 |
} |