Skip to main content

Module macros

Module macros 

Source
Expand description

Declarative macros generating ALTREP trait implementations.

These #[macro_export] macros are the public surface used by the #[derive(Altrep*)] proc-macros and by hand-rolled optionals/* impls. They expand to impl Altrep, impl AltVec, impl Alt<Family>, and the per-family InferBase impl for a given type.

Each per-family impl_alt<family>_from_data! macro takes a type plus an optional knob list of dataptr / serialize / subset (in canonical alphabetical order). The default arm (no knobs) is the materialising path — __impl_altvec_<family>_dataptr! provides a trivial AltrepDataptr<T> returning None, falling through to data2 materialisation.

Each family also has an impl_alt<family>_from_data_generic! sibling accepting a brace-delimited generic parameter list and where-clause ({$gen} $ty {$where}[, $knob]*) for generic types like struct Foo<T> { .. }. The plain macros forward to their _generic! sibling with empty {} brackets, so each family has exactly one emission body regardless of which form is called.

Note the iterator/stream data adaptors in altrep_data::iter / altrep_data::stream deliberately do not invoke these macros: they implement only the data-level traits and are meant to be wrapped by a concrete #[derive(Altrep*)] + #[altrep(manual)] struct (#1146).