cgp-macro-lib 0.7.0

Context-generic programming core component macros implemented as a library.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use quote::quote;
use syn::punctuated::Punctuated;
use syn::token::Comma;
use syn::{Ident, ItemStruct, parse2};

pub fn derive_component_name_struct(
    component_name: &Ident,
    component_params: &Punctuated<Ident, Comma>,
) -> syn::Result<ItemStruct> {
    if component_params.is_empty() {
        parse2(quote!(pub struct #component_name ;))
    } else {
        parse2(
            quote!(pub struct #component_name < #component_params > ( pub core::marker::PhantomData<( #component_params )> );),
        )
    }
}