Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrgvsv/to_phantom
Convert generics to PhantomData in proc macros
https://github.com/mrgvsv/to_phantom
Last synced: 13 days ago
JSON representation
Convert generics to PhantomData in proc macros
- Host: GitHub
- URL: https://github.com/mrgvsv/to_phantom
- Owner: MrGVSV
- License: other
- Created: 2023-04-28T03:17:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-28T03:20:38.000Z (over 1 year ago)
- Last Synced: 2024-12-13T00:53:30.320Z (about 1 month ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# `to_phantom`
[![Crates.io](https://img.shields.io/crates/v/to_phantom)](https://crates.io/crates/to_phantom)
[![Docs](https://img.shields.io/docsrs/to_phantom)](https://docs.rs/to_phantom/latest/to_phantom/)
[![License](https://img.shields.io/crates/l/to_phantom)](https://github.com/MrGVSV/to_phantom/blob/main/License.md)Easily convert [`Generics`](https://docs.rs/syn/latest/syn/struct.Generics.html)
to [`PhantomData`](https://doc.rust-lang.org/core/marker/struct.PhantomData.html) 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.```rust
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,
}
}
}
```