pub(crate) enum CoercionMapping {
Scalar {
r_native: TokenStream,
target: TokenStream,
},
Vec {
r_native_elem: TokenStream,
target_elem: TokenStream,
},
}Expand description
Result of coercion analysis for a type. Contains the R native type to extract from SEXP and the target type to coerce to.
Variants§
Scalar
Scalar coercion: extract R native type, coerce to target.
Fields
r_native: TokenStreamThe R-native scalar type to extract from the SEXP (e.g., i32 for R integers,
f64 for R reals). This is the type that R stores internally.
target: TokenStreamThe Rust target type to coerce into (e.g., u16, bool, f32).
Vec
Vec coercion: extract R native slice, coerce element-wise to Vec<target>.
Fields
r_native_elem: TokenStreamThe R-native element type of the source slice (e.g., i32 for integer vectors,
f64 for real vectors).
target_elem: TokenStreamThe Rust target element type for the resulting Vec (e.g., u16, bool, f32).
Implementations§
Source§impl CoercionMapping
impl CoercionMapping
Sourcepub(crate) fn from_type(ty: &Type) -> Option<Self>
pub(crate) fn from_type(ty: &Type) -> Option<Self>
Determines the coercion mapping for a Rust type, if it needs coercion from an R-native type.
Returns None if the type is already R-native (i32, f64, String, etc.)
or is not a recognized coercible type.
§Recognized coercions
- Scalar integer-like (
u16,i16,i8,u32,u64,i64,isize,usize): coerced fromi32(R’s native integer type). - Scalar
bool: coerced fromi32(R’s logical vectors usei32internally). - Scalar
f32: coerced fromf64(R’s native real type). Vec<T>variants: element-wise coercion from the corresponding R-native slice type.
Auto Trait Implementations§
impl Freeze for CoercionMapping
impl RefUnwindSafe for CoercionMapping
impl !Send for CoercionMapping
impl !Sync for CoercionMapping
impl Unpin for CoercionMapping
impl UnsafeUnpin for CoercionMapping
impl UnwindSafe for CoercionMapping
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 72 bytes
Size for each variant:
Scalar: 64 bytesVec: 64 bytes