pub(crate) struct ParamAttrs {
pub coerce: bool,
pub match_arg: bool,
pub several_ok: bool,
pub choices: Option<Vec<String>>,
pub default: Option<String>,
pub optional: bool,
pub omittable: bool,
pub no_default: bool,
pub either_noun: Option<String>,
pub checks: ExplicitChecks,
pub preconditions: Option<bool>,
pub formal: Option<LitStr>,
}Expand description
Collapsed per-parameter attribute state for a single function parameter.
Built during parsing from #[miniextendr(coerce | match_arg | several_ok | no_default | default = "…" | choices("…"))] on the argument. Accessors on
MiniextendrFunctionParsed query this struct rather than looking
through multiple side-tables.
Fields§
§coerce: bool§match_arg: bool§several_ok: bool§choices: Option<Vec<String>>§default: Option<String>§optional: boolOption<..> layer of a match_arg / choices parameter (#1473):
NULL means no choice, so the prelude skips the check for it and Rust
sees None. Unless Self::omittable is set too, the R formal is
NULL instead of the choice vector. Set from the parameter type by
classify_choice_param; together with several_ok only under an
Either layer (Option<Either<Vec<T>, R>>), since a plain
several_ok list already reads NULL as every choice.
omittable: boolMissing<..> layer of a match_arg / choices parameter (#1551): the
R formal keeps the choice vector, the prelude skips the check for an
omitted argument, and Rust sees Missing::Absent; a single choice reads
its formal passed whole the same way (Self::absent_formal, #2152).
Set by classify_choice_param.
no_default: boolno_default on a match_arg / choices parameter (#1828): the R
formal is the bare name instead of the choice vector (or NULL), so
an omitted argument is Missing::Absent under Missing<..> and R’s
missing-argument error otherwise. The prelude and the choice list do
not change. Set from the parameter’s no_default or the method’s
no_default(p).
either_noun: Option<String>Either<.., R> layer of a match_arg / choices parameter, over a
scalar choice (Either<T, R>) or a several_ok list
(Either<Vec<T>, R> / Either<Box<[T]>, R>): the R-facing name of the
R arm ("a data frame", see crate::type_inspect::r_value_noun)
for the @param line. The prelude checks only character or factor
input; anything else, NULL included, reaches Rust unchanged and
decodes as R. Set by classify_choice_param.
checks: ExplicitChecksR-side checks named by the author: inherits / not_inherits /
no_na.
preconditions: Option<bool>This parameter’s own decision on its type-derived R-side checks
(#1566), rank 1 of crate::r_preconditions::resolve_type_checks:
a Checked<T> / Unchecked<T> marker, the per-parameter
preconditions / no_preconditions, or a method’s
preconditions(x) / no_preconditions(x). Some(true) keeps them;
None defers to the function, impl and crate defaults.
formal: Option<LitStr>The declared R formal (#1842): a standalone function’s
formal = "conf.int" or a method’s formal(conf_int = "conf.int"),
with the literal that declared it. Read through
crate::r_wrapper_builder::Formals, never directly.
Implementations§
Source§impl ParamAttrs
impl ParamAttrs
Sourcepub(crate) fn leaves_argument_unforced(&self, default_ok: bool) -> bool
pub(crate) fn leaves_argument_unforced(&self, default_ok: bool) -> bool
Whether this parameter’s options leave its argument unforced, as a
Quoted / Quosure parameter needs (#1835): none but formal, which
only names it (#1842), and default when default_ok (a
Missing<Quoted> / Missing<Quosure> parameter, whose default only
writes the formal).
Sourcepub(crate) fn choice_formal(&self, choices: &str) -> Option<String>
pub(crate) fn choice_formal(&self, choices: &str) -> Option<String>
The R formal default of a choice parameter, given its choice list
(c("a", "b") or the write-time placeholder): NULL for the
Option<T> form (#1473), the choice list otherwise, including
Missing<Option<T>>, whose omission is reported by Missing (#1551).
None under no_default (#1828): the formal is the bare name. The
prelude spells the choice list out either way, so a match_arg
placeholder then lives in the prelude only.
Sourcepub(crate) fn absent_formal<'c>(&self, choices: &'c str) -> Option<&'c str>
pub(crate) fn absent_formal<'c>(&self, choices: &'c str) -> Option<&'c str>
The value that reads as omitted (#2152): choices, which is then the
formal (Self::choice_formal), for a single-choice Missing<..>
parameter. Its wrapper skips the check for a value identical() to
it and forwards the missing-argument sentinel in its place, so passing
the default shown in the usage line reaches Rust as Missing::Absent,
like leaving it out. None for every other parameter: a several_ok
list reads the whole vector as every choice, a parameter without
Missing reads it as the first choice, and a no_default one has no
vector in its formal.
Sourcepub(crate) fn choice_list(&self, c_ident: &str, key: &str) -> Option<String>
pub(crate) fn choice_list(&self, c_ident: &str, key: &str) -> Option<String>
The R expression for this parameter’s choice list, as its formal and
its prelude check spell it: the write-time placeholder of a
match_arg parameter (keyed by the C wrapper c_ident and the
parameter’s crate::match_arg_keys::param_key key), c("a", "b")
for choices(...), None for any other parameter.
Sourcepub(crate) fn choice_doc_suffix(&self) -> String
pub(crate) fn choice_doc_suffix(&self) -> String
The text after the quoted choice list in the auto-generated @param
line (One of "a", "b"<suffix>.): the other accepted values, then an
omission note. , or NULL for no choice for Option<T>,
, or a data frame for Either<T, DataFrame>,
, a data frame, or NULL for no choice for both,
, or NULL; omitting the argument or passing the whole list means no choice for Missing<Option<T>>, ; omitting the argument or passing the whole list means no choice for Missing<T> (#2152; see
Self::absent_formal), and nothing for a plain choice. A
Missing<Vec<T>> several_ok list, whose whole vector selects every
choice, says only ; omitting the argument means no choice. Under
no_default (#1828) the omission note goes (the author documents what
omission means) and the rest stays.
Sourcepub(crate) fn literal_choices_doc(&self) -> Option<String>
pub(crate) fn literal_choices_doc(&self) -> Option<String>
The auto-generated @param text of a choices(...) parameter:
One of "a", "b"<suffix>. (One or more of for several_ok), with
Self::choice_doc_suffix. None without a literal choice list; a
match_arg parameter’s text is only known at write time (its
placeholder, #210).
Sourcepub(crate) fn layered_leaf(&self) -> Option<ChoiceLeaf>
pub(crate) fn layered_leaf(&self) -> Option<ChoiceLeaf>
How the C wrapper decodes this parameter when a plain TryFromSexp
cannot: a match_arg parameter with a Missing / Option / Either
layer (MatchArgSeveral for a several_ok list, Either<Vec<T>, R>
included), or a choices parameter with an Either layer (its string
type or several_ok string list on the left). None for every other
parameter (a choices string type converts through TryFromSexp with
its Missing / Option layers; a plain several_ok container has its
own path).
Trait Implementations§
Source§impl Clone for ParamAttrs
impl Clone for ParamAttrs
Source§impl Debug for ParamAttrs
impl Debug for ParamAttrs
Auto Trait Implementations§
impl !Send for ParamAttrs
impl !Sync for ParamAttrs
impl Freeze for ParamAttrs
impl RefUnwindSafe for ParamAttrs
impl Unpin for ParamAttrs
impl UnsafeUnpin for ParamAttrs
impl UnwindSafe for ParamAttrs
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,
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: 240 bytes