Crates.io | to_phantom |
lib.rs | to_phantom |
version | 0.1.0 |
source | src |
created_at | 2023-04-28 03:19:12.14321 |
updated_at | 2023-04-28 03:19:12.14321 |
description | Convert generics to PhantomData in proc macros |
homepage | |
repository | https://github.com/MrGVSV/to_phantom |
max_upload_size | |
id | 851138 |
size | 22,887 |
to_phantom
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,
}
}
}