Expand description
#[derive(TryFromSexp)] / #[derive(IntoR)] — forward R↔Rust conversions
from a single-field newtype to its inner type.
For a newtype struct UserId(Uuid) (or struct UserId { inner: Uuid }):
#[derive(TryFromSexp)]generates the R → Rust direction: a scalarTryFromSexpimpl that forwards to the inner type, plus aFromRNewtypemarker impl. The marker lets the container blankets inminiextendr_api::newtypelight upVec<UserId>/Option<UserId>/Vec<Option<UserId>>— see issue #844.#[derive(IntoR)]generates the Rust → R direction: a scalarIntoRimpl that forwards to the inner type, plusIntoRNewtype(forOption/Vec<Option>) and a concreteIntoRVecElementimpl (forVec).
Direction is chosen by which derive you list — there are no attributes.
Some inner types are convertible in only one direction (a compiled
regex::Regex reads from R but cannot be written back): derive only
TryFromSexp for those.
ⓘ
#[derive(TryFromSexp)] // R -> Rust only
struct Pattern(regex::Regex);
#[derive(TryFromSexp, IntoR)] // round-trip
struct UserId(uuid::Uuid);Do not derive both IntoR and MatchArg on the same type: both would feed
the single IntoR for Vec<T> blanket slot and collide (E0119).
Structs§
- Newtype 🔒
- The single field of a newtype: its inner type plus how to wrap/unwrap it.
Functions§
- derive_
into_ r #[derive(IntoR)]: scalar forwardingIntoR+IntoRNewtypemarker (forOption/Vec<Option>blankets) + concreteIntoRVecElement(forVec).- derive_
try_ from_ sexp #[derive(TryFromSexp)]: scalar forwardingTryFromSexp+FromRNewtypemarker.- parse_
newtype 🔒 - where_
with 🔒 - Build a
whereclause that merges the struct’s existing predicates with one extra predicate (theInner: Traitbound the forwarding impl requires).