crate_paths_macros/
lib.rs

1mod impls;
2
3use proc_macro::TokenStream;
4
5/// usage:
6/// ```rust,ignore
7/// path!(std::sync::Arc);
8/// ```
9///
10/// This expands to
11/// ```rust,ignore
12/// #[allow(non_upper_case_globals)]
13/// pub const Arc: crate_paths::Path = {
14///     #[allow(unused_imports)]
15///     use std::sync::Arc as _;
16///
17///     crate_paths::Path::new("std::sync::Arc")
18/// };
19/// ```
20#[proc_macro]
21pub fn path(input: TokenStream) -> TokenStream {
22    impls::path(input)
23}
24
25/// Usage:
26///
27/// ```rust,ignore
28/// path_val!(std::sync::Arc);
29/// ```
30///
31/// This expands to:
32///
33/// ```rust,ignore
34/// {
35///   #[allow(unused_imports)]
36///   use std::sync::Arc as _;
37///
38///   crate_paths::Path::new("std::sync::Arc")
39/// }
40/// ```
41///
42/// Which you would later assign to a constant:
43///
44/// ```rust,ignore
45/// const SOME_CONSTANT: crate_paths::Path = path_val!(std::sync::Arc);
46/// ```
47#[proc_macro]
48pub fn path_val(input: TokenStream) -> TokenStream {
49    impls::path_val(input)
50}