pub fn impl_py_getter_def(cls: &syn::Type, property_type: PropertyType) -> Result<TokenStream> {
    let python_name = property_type.null_terminated_python_name()?;
    let deprecations = property_type.deprecations();
    let doc = property_type.doc();
    let getter_impl = match property_type {
        PropertyType::Descriptor {
            field: syn::Field {
                ident: Some(ident), ..
            },
            ..
        } => {
            // named struct field
            //quote!(_slf.#ident.clone())
            quote!(::std::clone::Clone::clone(&(_slf.#ident)))
        }
        PropertyType::Descriptor { field_index, .. } => {
            // tuple struct field
            let index = syn::Index::from(field_index);
            quote!(::std::clone::Clone::clone(&(_slf.#index)))
        }
        PropertyType::Function { spec, .. } => impl_call_getter(cls, spec)?,
    };

    let slf = match property_type {
        PropertyType::Descriptor { .. } => {
            SelfType::Receiver { mutable: false }.receiver(cls, ExtractErrorMode::Raise)
        }
        PropertyType::Function { self_type, .. } => {
            self_type.receiver(cls, ExtractErrorMode::Raise)
        }
    };
    Ok(quote! {
        ::pyo3::class::PyMethodDefType::Getter({
            #deprecations
            ::pyo3::class::PyGetterDef::new(
                #python_name,
                ::pyo3::class::methods::PyGetter({
                    unsafe extern "C" fn __wrap(
                        _slf: *mut ::pyo3::ffi::PyObject,
                        _: *mut ::std::os::raw::c_void
                    ) -> *mut ::pyo3::ffi::PyObject {
                        ::pyo3::callback::handle_panic(|_py| {
                            #slf
                            ::pyo3::callback::convert(_py, #getter_impl)
                        })
                    }
                    __wrap
                }),
                #doc
            )
        })
    })
}
// Used here for PropertyType::Function, used in pyclass for descriptors.
Used here for PropertyType::Function, used in pyclass for descriptors.
Used here for PropertyType :: Function used in pyclass for descriptors .
pub fn impl_py_getter_def(cls: &syn::Type, property_type: PropertyType) -> Result<TokenStream> {
    let python_name = property_type.null_terminated_python_name()?;
    let deprecations = property_type.deprecations();
    let doc = property_type.doc();
    let getter_impl = match property_type {
        PropertyType::Descriptor {
            field: syn::Field {
                ident: Some(ident), ..
            },
            ..
        } => {
            // named struct field
            //quote!(_slf.#ident.clone())
            quote!(::std::clone::Clone::clone(&(_slf.#ident)))
        }
        PropertyType::Descriptor { field_index, .. } => {
            // tuple struct field
            let index = syn::Index::from(field_index);
            quote!(::std::clone::Clone::clone(&(_slf.#index)))
        }
        PropertyType::Function { spec, .. } => impl_call_getter(cls, spec)?,
    };
    let slf = match property_type {
        PropertyType::Descriptor { .. } => {
            SelfType::Receiver { mutable: false }.receiver(cls, ExtractErrorMode::Raise)
        }
        PropertyType::Function { self_type, .. } => {
            self_type.receiver(cls, ExtractErrorMode::Raise)
        }
    };
    Ok(quote! {
        ::pyo3::class::PyMethodDefType::Getter({
            #deprecations
            ::pyo3::class::PyGetterDef::new(
                #python_name,
                ::pyo3::class::methods::PyGetter({
                    unsafe extern "C" fn __wrap(
                        _slf: *mut ::pyo3::ffi::PyObject,
                        _: *mut ::std::os::raw::c_void
                    ) -> *mut ::pyo3::ffi::PyObject {
                        ::pyo3::callback::handle_panic(|_py| {
                            #slf
                            ::pyo3::callback::convert(_py, #getter_impl)
                        })
                    }
                    __wrap
                }),
                #doc
            )
        })
    })
}
pub fn impl_py_getter_def ( cls : & syn :: Type , property_type : PropertyType ) -> Result < TokenStream > { let python_name = property_type . null_terminated_python_name ( ) ? ; let deprecations = property_type . deprecations ( ) ; let doc = property_type . doc ( ) ; let getter_impl = match property_type { PropertyType :: Descriptor { field : syn :: Field { ident : Some ( ident ) , .. } , .. } => { // named struct field //quote!(_slf.#ident.clone()) quote ! ( std clone Clone clone ( ( _slf ident ) ) ) } PropertyType :: Descriptor { field_index , .. } => { // tuple struct field let index = syn :: Index :: from ( field_index ) ; quote ! ( std clone Clone clone ( ( _slf index ) ) ) } PropertyType :: Function { spec , .. } => impl_call_getter ( cls , spec ) ? , } ; let slf = match property_type { PropertyType :: Descriptor { .. } => { SelfType :: Receiver { mutable : false } . receiver ( cls , ExtractErrorMode :: Raise ) } PropertyType :: Function { self_type , .. } => { self_type . receiver ( cls , ExtractErrorMode :: Raise ) } } ; Ok ( quote ! { pyo3 class PyMethodDefType Getter ( { deprecations pyo3 class PyGetterDef new ( python_name pyo3 class methods PyGetter ( { unsafe extern " " fn __wrap ( _slf mut pyo3 ffi PyObject mut std os raw c_void ) mut pyo3 ffi PyObject { pyo3 callback handle_panic ( py { slf pyo3 callback convert ( _py getter_impl ) } ) } __wrap } ) doc ) } ) } ) }
Used here for PropertyType::Function, used in pyclass for descriptors.
Used here for PropertyType :: Function used in pyclass for descriptors .
cls
&syn::Type
property_type
PropertyType