pub(crate) enum CoercionMapping {
Show 13 variants
Numeric,
Bool,
BoolVec,
NativeInt,
NativeIntVec,
NativeReal,
NativeRealVec,
OptionBool,
OptionBoolVec,
OptionNativeInt,
OptionNativeIntVec,
OptionNativeReal,
OptionNativeRealVec,
}Expand description
Conversion selected by coerce, shared by Rust conversion and R checks.
Variants§
Numeric
The non-native numeric scalars and vectors, and their Option /
Vec<Option<_>> forms, already have checked, multi-source converters.
Bool
Keep logical scalars and additionally accept integer zero or one.
BoolVec
Keep logical vectors and additionally accept integer zeros and ones.
NativeInt
Native i32: keep INTSXP, additionally accept whole-valued doubles,
logicals, and raws.
NativeIntVec
Native Vec<i32>: element-wise form of Self::NativeInt.
NativeReal
Native f64: keep REALSXP, additionally accept integers, logicals, and raws.
NativeRealVec
Native Vec<f64>: element-wise form of Self::NativeReal.
OptionBool
Option<bool>: NULL and NA read None, any other value converts
as Self::Bool (#2274).
OptionBoolVec
Vec<Option<bool>>: element-wise form of Self::OptionBool.
OptionNativeInt
Option<i32>: NULL and NA read None, any other value converts
as Self::NativeInt.
OptionNativeIntVec
Vec<Option<i32>>: element-wise form of Self::OptionNativeInt.
OptionNativeReal
Option<f64>: NULL and NA read None, any other value converts
as Self::NativeReal.
OptionNativeRealVec
Vec<Option<f64>>: element-wise form of Self::OptionNativeReal.
Implementations§
Source§impl CoercionMapping
impl CoercionMapping
Sourcepub(crate) fn from_type(ty: &Type) -> Option<Self>
pub(crate) fn from_type(ty: &Type) -> Option<Self>
Recognize the scalar and vector types supported by coerce.
Numeric conversion preserves all sources accepted by TryFromSexp:
integer, double, logical, and raw. Booleans extend their logical-only
converter with integer zero/one input. The native i32 / f64 scalars
and vectors, whose bare conversion accepts one SEXPTYPE, widen to the
same four sources (whole-valued doubles only for i32). Each of these
element types maps in four shapes: T, Vec<T>, Option<T> and
Vec<Option<T>>, and each shape also under Missing<..>, whose
sentinel reads Missing::Absent before the mapping converts a present
value. A Nullable<T> maps as Option<T> does (#2294), except as a
Vec element, which has no conversion; the caller wraps the
converter’s Option in Nullable. Borrowed slices and other types
keep TryFromSexp.
Sourcepub(crate) fn converter(&self) -> Option<&'static str>
pub(crate) fn converter(&self) -> Option<&'static str>
The miniextendr_api::from_r helper this mapping converts through,
or None for Self::Numeric, whose TryFromSexp impls already read
every source.
Auto Trait Implementations§
impl Forget for CoercionMapping
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> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§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: 1 byte
Size for each variant:
Numeric: 0 bytesBool: 0 bytesBoolVec: 0 bytesNativeInt: 0 bytesNativeIntVec: 0 bytesNativeReal: 0 bytesNativeRealVec: 0 bytesOptionBool: 0 bytesOptionBoolVec: 0 bytesOptionNativeInt: 0 bytesOptionNativeIntVec: 0 bytesOptionNativeReal: 0 bytesOptionNativeRealVec: 0 bytes