Function macro_tools::exposed::phantom::tuple

source ·
pub fn tuple(input: &Punctuated<GenericParam, Comma>) -> Type
Expand description

Constructs a PhantomData type tuple from the generic parameters of a struct.

This function generates a tuple type for PhantomData using the given generic parameters, which includes types, lifetimes, and const generics. It ensures that the generated tuple use all parameters.

§Parameters

  • input: A reference to a Punctuated< GenericParam, Comma> containing the generic parameters.

§Returns

Returns a syn::Type that represents a PhantomData tuple incorporating all the generic parameters.

§Examples

use syn::{parse_quote, punctuated::Punctuated, GenericParam, token::Comma};
use macro_tools::phantom::tuple;

let generics: Punctuated< GenericParam, Comma > = parse_quote! { 'a, T, const N : usize };
let phantom_type = tuple( &generics );
println!( "{}", quote::quote! { #phantom_type } );
// Output : ::core::marker::PhantomData< ( &'a (), *const T, N ) >