to_phantom

Crates.ioto_phantom
lib.rsto_phantom
version0.1.0
sourcesrc
created_at2023-04-28 03:19:12.14321
updated_at2023-04-28 03:19:12.14321
descriptionConvert generics to PhantomData in proc macros
homepage
repositoryhttps://github.com/MrGVSV/to_phantom
max_upload_size
id851138
size22,887
Gino Valente (MrGVSV)

documentation

README

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,
        }
    }
}
Commit count: 1

cargo fmt