Skip to main content

TryFromSexp

Derive Macro TryFromSexp 

Source
#[derive(TryFromSexp)]
Expand description

Derive TryFromSexp for a single-field newtype: forward the R → Rust conversion to the inner type.

Generates a scalar TryFromSexp impl that delegates to the inner type (so the newtype inherits its exact SEXPTYPE checks, NA policy, and error text), plus a FromRNewtype marker impl. The marker lets miniextendr-api’s container blankets light up Vec<T> / Option<T> / Vec<Option<T>> automatically.

§Usage

use uuid::Uuid;

#[derive(TryFromSexp)]            // R -> Rust only
struct Pattern(regex::Regex);

#[derive(TryFromSexp, IntoR)]     // round-trip; Vec/Option containers work too
struct UserId(Uuid);

Direction is chosen by which derive you list — derive only TryFromSexp for inner types that read from R but cannot be written back (e.g. regex::Regex).