Skip to main content

PreferExternalPtr

Derive Macro PreferExternalPtr 

Source
#[derive(PreferExternalPtr)]
Expand description

Derive PreferExternalPtr: return a type with a hand-written TypedExternal implementation as an R external pointer. #[derive(ExternalPtr)] already supplies IntoR; adding this derive to it creates conflicting implementations.

§Example

ⓘ
#[derive(PreferExternalPtr)]
struct Model { weights: Vec<f64> }

impl miniextendr_api::TypedExternal for Model {
    const TYPE_NAME: &'static str = "Model";
    const TYPE_NAME_CSTR: &'static [u8] = b"Model\0";
    const TYPE_ID_CSTR: &'static [u8] = concat!(module_path!(), "::Model\0").as_bytes();
}