pub(crate) fn expand_install_with(
        &mut self,
        input: &syn::DeriveInput,
        tokens: &Tokens,
        attrs: &DeriveAttrs,
        generics: &syn::Generics,
    ) -> Option<TokenStream> {
        let mut installers = Vec::new();

        if let Some(install_with) = &attrs.install_with {
            installers.push(quote_spanned! { input.span() =>
                #install_with(module)?;
            });
        }

        let ident = &input.ident;
        let (_, ty_generics, _) = generics.split_for_impl();
        match &input.data {
            syn::Data::Struct(st) => {
                for field in &st.fields {
                    let attrs = self.parse_field_attrs(&field.attrs)?;

                    let field_ident = match &field.ident {
                        Some(ident) => ident,
                        None => {
                            if !attrs.protocols.is_empty() {
                                self.errors.push(syn::Error::new_spanned(
                                    field,
                                    "only named fields can be used with protocol generators like `#[rune(get)]`",
                                ));
                                return None;
                            }

                            continue;
                        }
                    };

                    let ty = &field.ty;
                    let name = &syn::LitStr::new(&field_ident.to_string(), field_ident.span());

                    for protocol in &attrs.protocols {
                        installers.push((protocol.generate)(Generate {
                            tokens,
                            protocol,
                            attrs: &attrs,
                            ident,
                            field,
                            field_ident,
                            ty,
                            name,
                            ty_generics: &ty_generics,
                        }));
                    }
                }
            }
            syn::Data::Enum(..) => {
                self.errors.push(syn::Error::new_spanned(
                    input,
                    "`Any` not supported on enums",
                ));
                return None;
            }
            syn::Data::Union(..) => {
                self.errors.push(syn::Error::new_spanned(
                    input,
                    "`Any` not supported on unions",
                ));
                return None;
            }
        }

        Some(quote! {
            #(#installers)*
            Ok(())
        })
    }
/// Expannd the install into impl.
Expannd the install into impl.
Expannd the install into impl .
pub(crate) fn expand_install_with(
        &mut self,
        input: &syn::DeriveInput,
        tokens: &Tokens,
        attrs: &DeriveAttrs,
        generics: &syn::Generics,
    ) -> Option<TokenStream> {
        let mut installers = Vec::new();
        if let Some(install_with) = &attrs.install_with {
            installers.push(quote_spanned! { input.span() =>
                #install_with(module)?;
            });
        }
        let ident = &input.ident;
        let (_, ty_generics, _) = generics.split_for_impl();
        match &input.data {
            syn::Data::Struct(st) => {
                for field in &st.fields {
                    let attrs = self.parse_field_attrs(&field.attrs)?;
                    let field_ident = match &field.ident {
                        Some(ident) => ident,
                        None => {
                            if !attrs.protocols.is_empty() {
                                self.errors.push(syn::Error::new_spanned(
                                    field,
                                    "only named fields can be used with protocol generators like `#[rune(get)]`",
                                ));
                                return None;
                            }
                            continue;
                        }
                    };
                    let ty = &field.ty;
                    let name = &syn::LitStr::new(&field_ident.to_string(), field_ident.span());
                    for protocol in &attrs.protocols {
                        installers.push((protocol.generate)(Generate {
                            tokens,
                            protocol,
                            attrs: &attrs,
                            ident,
                            field,
                            field_ident,
                            ty,
                            name,
                            ty_generics: &ty_generics,
                        }));
                    }
                }
            }
            syn::Data::Enum(..) => {
                self.errors.push(syn::Error::new_spanned(
                    input,
                    "`Any` not supported on enums",
                ));
                return None;
            }
            syn::Data::Union(..) => {
                self.errors.push(syn::Error::new_spanned(
                    input,
                    "`Any` not supported on unions",
                ));
                return None;
            }
        }
        Some(quote! {
            #(#installers)*
            Ok(())
        })
    }
pub ( crate ) fn expand_install_with ( & mut self , input : & syn :: DeriveInput , tokens : & Tokens , attrs : & DeriveAttrs , generics : & syn :: Generics , ) -> Option < TokenStream > { let mut installers = Vec :: new ( ) ; if let Some ( install_with ) = & attrs . install_with { installers . push ( quote_spanned ! { input span ( ) install_with ( module ) } ) ; } let ident = & input . ident ; let ( _ , ty_generics , _ ) = generics . split_for_impl ( ) ; match & input . data { syn :: Data :: Struct ( st ) => { for field in & st . fields { let attrs = self . parse_field_attrs ( & field . attrs ) ? ; let field_ident = match & field . ident { Some ( ident ) => ident , None => { if ! attrs . protocols . is_empty ( ) { self . errors . push ( syn :: Error :: new_spanned ( field , " " , ) ) ; return None ; } continue ; } } ; let ty = & field . ty ; let name = & syn :: LitStr :: new ( & field_ident . to_string ( ) , field_ident . span ( ) ) ; for protocol in & attrs . protocols { installers . push ( ( protocol . generate ) ( Generate { tokens , protocol , attrs : & attrs , ident , field , field_ident , ty , name , ty_generics : & ty_generics , } ) ) ; } } } syn :: Data :: Enum ( .. ) => { self . errors . push ( syn :: Error :: new_spanned ( input , " " , ) ) ; return None ; } syn :: Data :: Union ( .. ) => { self . errors . push ( syn :: Error :: new_spanned ( input , " " , ) ) ; return None ; } } Some ( quote ! { ( installers ) Ok ( ( ) ) } ) }
Expannd the install into impl.
Expannd the install into impl .
&mut self
input
&syn::DeriveInput
tokens
&Tokens
attrs
&DeriveAttrs
generics
&syn::Generics
&mut self
input
&syn::DeriveInput
tokens
&Tokens
attrs
&DeriveAttrs
generics
&syn::Generics