Skip to main content

from_sexp

Function from_sexp 

Source
pub unsafe fn from_sexp<T>(x: SEXP) -> T
where T: TryFromSexp, T::Error: Display,
Expand description

Convert an R SEXP to a Rust type, panicking on failure.

Attempts TryFromSexp::try_from_sexp. Generated shims catch failures with with_r_unwind_protect_shim; View result conversions unwind to the consumer’s outer boundary.

§Type Parameters

§Arguments

  • x - R value to convert

§Returns

The converted Rust value.

§Safety

  • x must be a valid SEXP
  • Must be called on R’s main thread

§Panics

Panics if conversion fails, using TryFromSexp’s error type’s Display impl. The error is dropped during Rust unwinding.

§Example

ⓘ
// In a method shim:
let arg0: i32 = unsafe { from_sexp(argv[0]) };
let arg1: String = unsafe { from_sexp(argv[1]) };