pub trait RNativeType:
Sized
+ Copy
+ 'static {
const SEXP_TYPE: SEXPTYPE;
// Required methods
unsafe fn dataptr_mut(sexp: SEXP) -> *mut Self;
fn elt(sexp: SEXP, i: isize) -> Self;
}Expand description
Marker trait for types that correspond to R’s native vector element types.
This enables blanket implementations for TryFromSexp and safe conversions.
Required Associated Constants§
Required Methods§
Sourceunsafe fn dataptr_mut(sexp: SEXP) -> *mut Self
unsafe fn dataptr_mut(sexp: SEXP) -> *mut Self
Get mutable pointer to vector data.
For empty vectors (length 0), returns an aligned dangling pointer rather than
R’s internal 0x1 sentinel, which isn’t properly aligned for most types.
This allows safe creation of zero-length slices with std::slice::from_raw_parts_mut.
§Safety
sexpmust be a valid, non-null SEXP of the corresponding vector type.- For ALTREP vectors, this may trigger materialization.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.