Expand description
Type coercion traits for converting Rust types to R native types.
R has a fixed set of native scalar types:
i32(INTSXP) - 32-bit signed integerf64(REALSXP) - 64-bit floating pointRLogical(LGLSXP) - logical (TRUE/FALSE/NA)u8(RAWSXP) - raw bytesRcomplex(CPLXSXP) - complex numbers
ยงTraits
Coerce<R>- infallible coercion (identity, widening)TryCoerce<R>- fallible coercion (narrowing, overflow-possible)
ยงExamples
โ
use miniextendr_api::coerce::Coerce;
// Scalar coercion
let x: i32 = 42i8.coerce();
// Element-wise slice coercion
let slice: &[i8] = &[1, 2, 3];
let vec: Vec<i32> = slice.coerce();Macrosยง
- impl_
identity ๐ - impl_
nonzero_ ๐from_ self - impl_
try_ ๐i8 - impl_
try_ ๐i16 - impl_
try_ ๐i32 - impl_
try_ ๐u8 - impl_
try_ ๐u16 - impl_
tuple_ ๐coerce - Macro to implement element-wise Coerce for tuples.
Structsยง
- Coerced
- Wrapper for values coerced from an R native type during conversion.
Enumsยง
- Coerce
Error - Error type for coercion failures.
- Logical
Coerce Error - Error type for logical coercion failures.