pub trait IntoRAs<Target> {
// Required method
fn into_r_as(self) -> Result<SEXP, StorageCoerceError>;
}Expand description
Storage-directed conversion to R SEXP.
This trait allows converting Rust values to R with an explicit target storage type. The conversion is value-based: it succeeds if all values fit the target type, and fails otherwise.
§Target Types
i32→ R integer (INTSXP)f64→ R numeric (REALSXP)RLogical→ R logical (LGLSXP)u8→ R raw (RAWSXP)String→ R character (STRSXP)
§Example
ⓘ
use miniextendr_api::IntoRAs;
// Convert i64 to R integer (if values fit)
let x: Vec<i64> = vec![1, 2, 3];
let sexp = x.into_r_as::<i32>()?;
// Convert f64 to R integer (if values are integral)
let y: Vec<f64> = vec![1.0, 2.0, 3.0];
let sexp = y.into_r_as::<i32>()?;Required Methods§
Sourcefn into_r_as(self) -> Result<SEXP, StorageCoerceError>
fn into_r_as(self) -> Result<SEXP, StorageCoerceError>
Convert to R SEXP with the specified target storage type.