1 unstable release

0.1.0 Apr 28, 2023

#1471 in Procedural macros

Download history 58/week @ 2024-04-01 74/week @ 2024-04-08 20/week @ 2024-04-15 23/week @ 2024-04-22 15/week @ 2024-04-29 18/week @ 2024-05-06 25/week @ 2024-05-13 25/week @ 2024-05-20 48/week @ 2024-05-27 42/week @ 2024-06-03 40/week @ 2024-06-10 32/week @ 2024-06-17 23/week @ 2024-06-24 3/week @ 2024-07-08 22/week @ 2024-07-15

52 downloads per month
Used in 3 crates (via bevy_proto_derive)

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

~260–710KB
~17K SLoC