Skip to main content

Module list_derive

Module list_derive 

Source
Expand description

§List and Preference Derive Macros

This module implements derive macros for bidirectional Rust struct <-> R list conversion, plus “preference” derives that control how a type is converted to R when returned from #[miniextendr] functions.

§List Derives

  • #[derive(IntoList)] – Rust struct -> R named/unnamed list
  • #[derive(TryFromList)] – R list -> Rust struct

§Preference Derives

These marker derives select the IntoR strategy for a type. Only one preference derive should be applied to a given type:

  • #[derive(PreferList)] – convert via IntoList::into_list
  • #[derive(PreferExternalPtr)] – wrap in ExternalPtr::new
  • #[derive(PreferDataFrame)] – convert via ColumnSource::into_column_list
  • #[derive(PreferRNativeType)] – convert via AsRNative wrapper

Stacking two of them is a conflict: each derive emits a fixed-name marker const (prefer_conflict_marker), so a second Prefer* produces a guided “duplicate definitions” error pointing at the call-site As* wrappers as the way to choose a representation per return value (see #870).

§Field Attributes

  • #[into_list(ignore)] – skip this field during IntoList/TryFromList conversion. For TryFromList, ignored fields are filled with Default::default().

Functions§

derive_into_list
Derive IntoList for structs (Rust -> R).
derive_prefer_data_frame
Derive PreferDataFrame: emits an IntoR impl that converts to R via ColumnSource::into_column_list, then into_sexp.
derive_prefer_externalptr
Derive PreferExternalPtr: emits an IntoR impl that wraps the value in ExternalPtr::new before converting to SEXP.
derive_prefer_list
Derive PreferList: emits an IntoR impl that converts to R by first calling IntoList::into_list, then into_sexp.
derive_prefer_rnative
Derive PreferRNativeType: emits an IntoR impl that wraps the value in AsRNative(self) before calling IntoR::into_sexp.
derive_try_from_list
Derive TryFromList for structs (R -> Rust).
field_is_ignored 🔒
Check whether a struct field has the #[into_list(ignore)] attribute.
prefer_conflict_marker 🔒
Emit a fixed-name conflict marker so that stacking two Prefer* derives on a single type produces a guided compile error instead of a cryptic E0119 conflicting-IntoR-implementation error.