fn derive_altrep_generic(
input: DeriveInput,
data_trait_path: TokenStream,
gen_elt_impl: impl FnOnce(Option<&Ident>, Option<&Ident>) -> TokenStream,
family: &AltrepFamilyConfig<'_>,
) -> Result<TokenStream>Expand description
Shared implementation for all non-list ALTREP derive macros.
Generates three items:
impl AltrepLen– delegates to the detected/specified length fieldimpl Alt*Data– the family-specific data trait with anelt()method- Low-level trait impls via
AltrepAttrs::generate_lowlevel
§Arguments
input– TheDeriveInputfrom the proc-macro.data_trait_path– The fully qualified path to the data trait (e.g.,::miniextendr_api::altrep_data::AltIntegerData).gen_elt_impl– A closure that receives the optionalelt_fieldand returns a token stream for thefn elt(...)method body. Ifelt_fieldisSome, the closure typically returnsself.{field}; ifNone, it returns a family-appropriate default (NA_INTEGER,f64::NAN,0u8,Logical::Na,None, orRcomplex { NAN, NAN }).family– TheAltrepFamilyConfigfor this type family.
§Errors
Returns Err if attribute parsing fails, no length field can be found, or
option validation fails.