pub enum Missing<T> {
Present(T),
Absent,
}Expand description
Wrapper type that detects if an R argument was not passed (missing).
This corresponds to R’s missing() function. When a function parameter
has type Missing<T>, it will be Missing::Absent if the caller didn’t
provide that argument, or Missing::Present(value) if they did.
§Example
use miniextendr_api::{miniextendr, Missing};
#[miniextendr]
fn maybe_square(x: Missing<f64>) -> f64 {
match x {
Missing::Present(val) => val * val,
Missing::Absent => 0.0,
}
}In R:
maybe_square(5) # 25
maybe_square() # 0Variants§
Implementations§
Source§impl<T> Missing<T>
impl<T> Missing<T>
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
Returns true if the argument was provided.
Sourcepub fn is_missing(&self) -> bool
pub fn is_missing(&self) -> bool
Returns true if the argument was not provided.
Named to match R’s missing() function.
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Convert to Option<T>, returning None if missing.
Sourcepub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
Returns the contained value or computes it from a closure.
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Missing<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Missing<U>
Maps Missing<T> to Missing<U> by applying a function.
Trait Implementations§
impl<T: Copy> Copy for Missing<T>
Source§impl<T: Eq> Eq for Missing<T>
impl<T: Eq> Eq for Missing<T>
Source§#[doc(hidden)]fn assert_fields_are_eq(&self)
#[doc(hidden)]fn assert_fields_are_eq(&self)
derive_eq_internals)1.0.0 (const: unstable) · Source§#[doc(hidden)]fn assert_receiver_is_total_eq(&self)
#[doc(hidden)]fn assert_receiver_is_total_eq(&self)
implementation detail of #[derive(Eq)]
Source§impl<T: PartialEq> PartialEq for Missing<T>
impl<T: PartialEq> PartialEq for Missing<T>
impl<T: PartialEq> StructuralPartialEq for Missing<T>
Auto Trait Implementations§
impl<T> Freeze for Missing<T>where
T: Freeze,
impl<T> RefUnwindSafe for Missing<T>where
T: RefUnwindSafe,
impl<T> Send for Missing<T>where
T: Send,
impl<T> Sync for Missing<T>where
T: Sync,
impl<T> Unpin for Missing<T>where
T: Unpin,
impl<T> UnsafeUnpin for Missing<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Missing<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Printable for 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: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.