to_phantom 0.1.0

Convert generics to PhantomData in proc macros
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented1 out of 2 items with examples
  • Size
  • Source code size: 23.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.19 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • MrGVSV/to_phantom
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MrGVSV

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,
        }
    }
}