Skip to main content

__impl_altrep_base

Macro __impl_altrep_base 

Source
#[doc(hidden)]
macro_rules! __impl_altrep_base { ($ty:ty) => { ... }; ($ty:ty, with_serialize) => { ... }; ({$($gen:tt)*} $ty:ty {$($whr:tt)*}, $guard:ident) => { ... }; ({$($gen:tt)*} $ty:ty {$($whr:tt)*}, $guard:ident, with_serialize) => { ... }; ($ty:ty, $guard:ident) => { ... }; ($ty:ty, $guard:ident, with_serialize) => { ... }; }
Expand description

Internal macro: impl Altrep with just length, optionally plus serialization.

§Arms

__impl_altrep_base!($ty);                            // length only, default RUnwind guard
__impl_altrep_base!($ty, $guard);                    // length only, explicit guard
__impl_altrep_base!($ty, with_serialize);            // length + serialize, default guard
__impl_altrep_base!($ty, $guard, with_serialize);    // length + serialize, explicit guard

The with_serialize flag implements both:

  • serialized_state(x) (save-side)
  • unserialize(class, state) (load-side)

The unserialize implementation reconstructs the backing Rust value via [AltrepSerialize::unserialize] and then creates a fresh ALTREP instance via R_new_altrep(class, data1, SEXP::nil()) where data1 is an ExternalPtr<$ty>.

This matches the proc-macro-generated IntoR::into_sexp behavior (data is stored in data1, and data2 is R_NilValue).