1 unstable release

0.1.0 Apr 28, 2023

#1226 in Procedural macros

Download history 47/week @ 2023-12-18 4/week @ 2023-12-25 3/week @ 2024-01-08 15/week @ 2024-01-15 1/week @ 2024-01-22 8/week @ 2024-01-29 5/week @ 2024-02-12 16/week @ 2024-02-19 47/week @ 2024-02-26 23/week @ 2024-03-04 35/week @ 2024-03-11 23/week @ 2024-03-18 25/week @ 2024-03-25 58/week @ 2024-04-01

146 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

~315–770KB
~18K SLoC