pub unsafe fn to_sexp<T>(x: T) -> SEXPwhere
T: IntoR,Expand description
Convert a Rust value to an R SEXP.
Calls IntoR::into_sexp to produce an R value.
Used in trait ABI method shims for the result, and by a trait’s View for
each argument, which the shim reads back with TryFromSexp (or
TryFromRoot for borrowed views). So a trait-method parameter type needs
both directions:
the reading markers cross as their inner value
(AsNumeric as Option<f64>, and so on) and
AsFromStr as its text; Missing<T> goes
through missing_to_sexp instead. Parameter checks such as no_na run
in the implementing method’s R-facing wrappers, so they check R arguments,
not the typed values a View caller passes.
§Type Parameters
T- Source Rust type (must implementIntoR)
§Arguments
x- Rust value to convert
§Returns
R SEXP representation of the value.
§Safety
- Must be called on R’s main thread
- The returned SEXP must be protected if used across R allocations
§Example
ⓘ
// In a method shim:
let result: f64 = self_ref.area();
unsafe { to_sexp(result) }