[partial]
This commit is contained in:
@@ -4,9 +4,9 @@ use syn::*;
|
||||
pub fn builder_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
dbg!(derive_builder::derive(input)
|
||||
derive_builder::derive(input)
|
||||
.unwrap_or_else(|err| err.into_compile_error())
|
||||
.into())
|
||||
.into()
|
||||
}
|
||||
|
||||
mod derive_builder {
|
||||
@@ -16,6 +16,39 @@ mod derive_builder {
|
||||
use syn::token::Comma;
|
||||
use syn::*;
|
||||
|
||||
pub struct Builder {}
|
||||
|
||||
impl Builder {
|
||||
pub fn expr(&self) -> syn::ExprStruct {
|
||||
todo!()
|
||||
}
|
||||
pub fn ty(&self) -> syn::Type {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn ty_empty(&self) -> syn::Type {
|
||||
syn::Type::Path(TypePath {
|
||||
qself: None,
|
||||
path: syn::Path {
|
||||
leading_colon: None,
|
||||
segments: Punctuated::from_iter(vec),
|
||||
args: core::iter::repeat::<GenericArgument>(parse_quote!(
|
||||
#crate_name::Empty
|
||||
))
|
||||
.take(gf.len() as usize - 1)
|
||||
.collect(),
|
||||
gt_token: Token),
|
||||
}),
|
||||
}]),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn derive(input: DeriveInput) -> Result<TokenStream> {
|
||||
let crate_name: syn::Path = parse_quote!(::comptime_builder);
|
||||
let fields = match input.data {
|
||||
@@ -37,26 +70,6 @@ mod derive_builder {
|
||||
// Use Generic type T{0..} to represent the fields
|
||||
let gf = generic_fields("T", fields)?;
|
||||
|
||||
let empty_builder_type: syn::Type = syn::Type::Path(TypePath {
|
||||
qself: None,
|
||||
path: syn::Path {
|
||||
leading_colon: None,
|
||||
segments: Punctuated::from_iter(vec),
|
||||
args: core::iter::repeat::<GenericArgument>(parse_quote!(
|
||||
#crate_name::Empty
|
||||
))
|
||||
.take(gf.len() as usize - 1)
|
||||
.collect(),
|
||||
gt_token: Token),
|
||||
}),
|
||||
}]),
|
||||
},
|
||||
});
|
||||
|
||||
let empty_builder = syn::ExprStruct {
|
||||
attrs: vec![],
|
||||
qself: None,
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ pub struct MyStruct<T1, T2> {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
||||
// echo hello
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user