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, aborting via Rf_error on failure.

Attempts TryFromSexp::try_from_sexp and calls rf_error (R longjmp, never returns) if conversion fails.

§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

§Errors

Calls rf_error (never returns) if conversion fails. Error messages are generated by TryFromSexp’s error type’s Display impl.

§Example

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