Skip to main content

Altrep

Derive Macro Altrep 

Source
#[derive(Altrep)]
{
    // Attributes available to this derive:
    #[altrep]
}
Expand description

Derive ALTREP registration for a data struct.

Generates TypedExternal, AltrepClass, RegisterAltrep, IntoR, linkme registration entry, and Ref/Mut accessor types.

The struct must already have low-level ALTREP traits implemented. For most use cases, prefer a family-specific derive: #[derive(AltrepInteger)], #[derive(AltrepReal)], etc. Use #[altrep(manual)] on a family derive to skip data trait generation when you provide your own AltrepLen + Alt*Data impls.

§Attributes

  • #[altrep(class = "Name")] — custom ALTREP class name (defaults to struct name)

§Example

// Prefer family derives with manual:
#[derive(AltrepInteger)]
#[altrep(manual, class = "MyCustom", serialize)]
struct MyData { ... }

impl AltrepLen for MyData { ... }
impl AltIntegerData for MyData { ... }