extendr_api::scalar::macros

Macro gen_from_primitive

Source
macro_rules! gen_from_primitive {
    ($type : tt, $type_prim : tt) => { ... };
}
Expand description

Generates an implementation of type conversion Traits from a primitive type

This macro requires the following arguments:

  • $type - The Type the unary operator Trait is implemented for
  • $type_prim - The primitive Rust scalar type that corresponds to $type

Example Usage:

gen_from_primitive!(Rint, i32);

The ‘example usage’ implements the following trait definitions:

  • From<i32> for Rint
  • From<Option<i32>> for Rint