1 unstable release

0.1.0 Apr 28, 2023

#2714 in Procedural macros

Download history 15/week @ 2025-07-23 1/week @ 2025-08-06 13/week @ 2025-08-13 33/week @ 2025-08-20 52/week @ 2025-08-27 58/week @ 2025-09-03 28/week @ 2025-09-10 23/week @ 2025-09-17 61/week @ 2025-09-24 30/week @ 2025-10-01 26/week @ 2025-10-08 38/week @ 2025-10-15 37/week @ 2025-10-22 10/week @ 2025-10-29 10/week @ 2025-11-05

99 downloads per month
Used in 6 crates (3 directly)

MIT/Apache

9KB
57 lines

to_phantom

Crates.io Docs License

Easily convert Generics to PhantomData in your proc macros.

This is useful for when creating custom types in a proc macro that use the generics from some other type. The PhantomData allows those generics to exist on the type without needing dedicated fields using them.

use to_phantom::ToPhantom;

fn create_helper(input: DeriveInput) -> TokenStream {
    let generics = input.generics();
    let phantom = generics.to_phantom();

    quote! {
        pub struct MyHelperStruct #generics {
            phantom: #phantom,
        }
    }
}

Dependencies

~145–550KB
~13K SLoC