pub enum MatchArgError {
InvalidType {
actual: SEXPTYPE,
choices: &'static [&'static str],
aliases: &'static [MatchArgAlias],
},
InvalidLength {
actual: usize,
choices: &'static [&'static str],
aliases: &'static [MatchArgAlias],
},
IsNa {
choices: &'static [&'static str],
aliases: &'static [MatchArgAlias],
},
NoMatch {
input: String,
choices: &'static [&'static str],
aliases: &'static [MatchArgAlias],
},
}Expand description
Error type for MatchArg conversion failures.
Every variant carries the type’s choices and aliases, so an error can say
what the value must be ('mode' should be one of "fast", "slow" (or "quick" for "fast")) whichever way it was wrong.
Variants§
InvalidType
The SEXP was not a character or factor type.
Fields
aliases: &'static [MatchArgAlias]The type’s aliases (MatchArg::ALIASES).
InvalidLength
The input had length != 1.
Fields
aliases: &'static [MatchArgAlias]The type’s aliases (MatchArg::ALIASES).
IsNa
The input was NA.
Fields
aliases: &'static [MatchArgAlias]The type’s aliases (MatchArg::ALIASES).
NoMatch
No choice matched the input.
Fields
aliases: &'static [MatchArgAlias]The type’s aliases (MatchArg::ALIASES).
Implementations§
Source§impl MatchArgError
impl MatchArgError
Sourcefn invalid_type<T: MatchArg>(actual: SEXPTYPE) -> Self
fn invalid_type<T: MatchArg>(actual: SEXPTYPE) -> Self
InvalidType for the choices of T.
Sourcefn invalid_length<T: MatchArg>(actual: usize) -> Self
fn invalid_length<T: MatchArg>(actual: usize) -> Self
InvalidLength for the choices of T.
Sourcepub fn choices(&self) -> &'static [&'static str]
pub fn choices(&self) -> &'static [&'static str]
The choices the value should have been one of.
Sourcepub fn aliases(&self) -> &'static [MatchArgAlias]
pub fn aliases(&self) -> &'static [MatchArgAlias]
The aliases of the choices, listed and unlisted.
Sourcepub fn expectation(&self) -> String
pub fn expectation(&self) -> String
What the value must be, in R terms: one of "fast", "slow", with the
listed aliases after the choices (one of "fast", "slow" (or "quick" for "fast")). An Either whose arms both refused a value names a
match_arg arm with it ('x' must be one of "oral", "bolus", or a single double: got logical, #1594).
Sourcepub fn arg_error(&self, param: &str) -> ArgError
pub fn arg_error(&self, param: &str) -> ArgError
The argument error the generated wrapper’s match_arg check
(.miniextendr_match_arg) raises for this value of parameter param
(its R name), word for word (#1741):
InvalidType:'mode' must be NULL or a character vectorInvalidLength:'mode' must be of length 1IsNa,NoMatch:'mode' should be one of "fast", "safe", then the listed aliases ('mode' should be one of "fast", "safe" (or "quick" for "fast"), #2148)
The choices and the aliases are quoted as R’s dQuote(choices, FALSE) quotes them, without escapes. match_arg_param returns it;
ArgError::raise raises it as that condition. The generated conversion of a match_arg
type, with or without #[miniextendr(match_arg)], raises its message
too (#1767).
Sourcepub(crate) fn arg_message(&self, param: &str, formal: &[&str]) -> String
pub(crate) fn arg_message(&self, param: &str, formal: &[&str]) -> String
The message of arg_error, with the choices listed
in the order of formal, the choices of the parameter’s R formal:
T::CHOICES, or those of a default = "..." parameter, which lists
its default first (match_arg_param_with_default). The listed
aliases follow in the order of T::CHOICES whatever the formal, as
the wrappers writer renders them for the R check.
Sourcepub(crate) fn r_reason(&self, expected_known: bool) -> String
pub(crate) fn r_reason(&self, expected_known: bool) -> String
The reason of this error in R terms, after <expected>: when an
Either names this arm in an argument error (#1591): got "zzz",
got numeric, got length 2, NA is not allowed. With
expected_known = false (nothing before the reason names the choices)
it is the Display text, which says what was expected.
Trait Implementations§
Source§impl Clone for MatchArgError
impl Clone for MatchArgError
Source§impl ConversionErrBuiltin for MatchArgError
impl ConversionErrBuiltin for MatchArgError
fn __mx_conversion_parts(&self, expected_known: bool) -> ErrParts
Source§impl ConversionExpectBuiltin for MatchArgError
impl ConversionExpectBuiltin for MatchArgError
fn __mx_conversion_expectation(&self) -> Option<String>
Source§impl Debug for MatchArgError
impl Debug for MatchArgError
Source§impl Display for MatchArgError
The text is complete on its own, for a conversion outside an argument:
expected one of "fast", "slow", got "zzz", expected a string or factor, got numeric.
impl Display for MatchArgError
The text is complete on its own, for a conversion outside an argument:
expected one of "fast", "slow", got "zzz", expected a string or factor, got numeric.
Source§impl Error for MatchArgError
impl Error for MatchArgError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Source§#[doc(hidden)]fn type_id(&self, _: Internal) -> TypeIdwhere
Self: 'static,
#[doc(hidden)]fn type_id(&self, _: Internal) -> TypeIdwhere
Self: 'static,
error_type_id)TypeId of self.1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<MatchArgError> for SexpError
Kept whole, so a TryFromSexp whose error is SexpError (the one
#[derive(MatchArg)] emits) still reports the choices.
impl From<MatchArgError> for SexpError
Kept whole, so a TryFromSexp whose error is SexpError (the one
#[derive(MatchArg)] emits) still reports the choices.
Source§fn from(e: MatchArgError) -> Self
fn from(e: MatchArgError) -> Self
Auto Trait Implementations§
impl Freeze for MatchArgError
impl RefUnwindSafe for MatchArgError
impl Send for MatchArgError
impl Sync for MatchArgError
impl Unpin for MatchArgError
impl UnsafeUnpin for MatchArgError
impl UnwindSafe for MatchArgError
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> ConsumingFallible for Twhere
T: Clone,
Source§impl<T> RDebug for Twhere
T: Debug,
impl<T> RDebug for Twhere
T: Debug,
Source§impl<T> RError for Twhere
T: Error,
impl<T> RError for Twhere
T: Error,
Source§fn error_message(&self) -> String
fn error_message(&self) -> String
Source§fn error_chain(&self) -> Vec<String>
fn error_chain(&self) -> Vec<String>
Source§fn error_chain_length(&self) -> i32
fn error_chain_length(&self) -> i32
Source§#[doc(hidden)]unsafe extern "C" fn __RError_error_message_shim(
data: *mut c_void,
argc: i32,
argv: *const SEXP,
) -> SEXP
#[doc(hidden)]unsafe extern "C" fn __RError_error_message_shim(
data: *mut c_void,
argc: i32,
argv: *const SEXP,
) -> SEXP
RError::error_message. Read moreSource§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: 56 bytes
Size for each variant:
InvalidType: 48 bytesInvalidLength: 48 bytesIsNa: 40 bytesNoMatch: 56 bytes