pub struct RArgumentBuilder<'a> {
inputs: &'a Punctuated<FnArg, Comma>,
dots_index: Option<usize>,
dots_kind: Option<DotsKind>,
skip_first: bool,
defaults: HashMap<String, String>,
absent_formals: HashMap<String, String>,
formals: Formals,
}Expand description
Builder for R function formal parameters and call arguments.
Handles:
- R formals: the declared
formal = ".."(#1842), else the Rust name without leading underscores (_x→x) - Unit type defaults (
()→= NULL) - Dots: the
&Dotsparameter is...in the formals andlist(...)in the call arguments, at its own position in the signature; aLazyDotsparameter is...too, andenvironment()in the call arguments, which passes the dots unforced (#1892) - The argument count: an
NArgsparameter is no formal andnargs()in the call arguments, at its own position (#1860) - Consistent formatting across function and method wrappers
Fields§
§inputs: &'a Punctuated<FnArg, Comma>The function’s input parameters from the parsed Rust signature.
dots_index: Option<usize>Position of the &Dots / LazyDots parameter in inputs (receiver
included, the way both build loops count). Its Rust name never reaches
R: the formal is always plain ....
dots_kind: Option<DotsKind>Which ... type it is: what the call arguments pass at its position.
skip_first: boolIf true, skip the first parameter (used for self/&self in method wrappers,
since the self argument is handled separately by DotCallBuilder::with_self).
defaults: HashMap<String, String>Parameter default values from #[miniextendr(default = "...")] attributes.
Keys are R formals (Formals::of), values are R expressions emitted
verbatim (e.g., "1L", "c(1, 2, 3)", "NULL").
absent_formals: HashMap<String, String>The single-choice Missing<..> parameters that read a value
identical() to their formal as omitted (#2152), R formal → the
formal’s default (see
crate::miniextendr_fn::ParamAttrs::absent_formal).
formals: FormalsThe R formal of each parameter (#1842).
Implementations§
Source§impl<'a> RArgumentBuilder<'a>
impl<'a> RArgumentBuilder<'a>
Sourcepub fn new(inputs: &'a Punctuated<FnArg, Comma>) -> Self
pub fn new(inputs: &'a Punctuated<FnArg, Comma>) -> Self
Create a new builder for the given function inputs.
Sourcepub fn with_formals(self, formals: Formals) -> Self
pub fn with_formals(self, formals: Formals) -> Self
Name each parameter by its R formal (#1842): the declared
formal = "..", else the normalized Rust name (the default). The
keys of Self::with_defaults and Self::with_absent_formals are
these formals.
Sourcepub fn with_absent_formals(
self,
absent_formals: HashMap<String, String>,
) -> Self
pub fn with_absent_formals( self, absent_formals: HashMap<String, String>, ) -> Self
Add the Missing<..> choice parameters that read a value identical()
to their formal as omitted (#2152), keyed by R formal, valued by that
formal’s default (see
crate::miniextendr_fn::absent_formals_by_r_name).
Sourcepub fn with_defaults(self, defaults: HashMap<String, String>) -> Self
pub fn with_defaults(self, defaults: HashMap<String, String>) -> Self
Add parameter defaults from #[miniextendr(default = "...")] attributes.
Keys are R formals (see Self::with_formals; without a declared
formal, the Rust name without leading underscores), values are R
expression strings emitted verbatim into formals.
Sourcepub fn skip_first(self) -> Self
pub fn skip_first(self) -> Self
Skip the first parameter (for instance methods with self).
Sourcepub fn build_formals(&self) -> String
pub fn build_formals(&self) -> String
Build R formal parameters string (for function signature).
§Returns
Comma-separated parameter list, e.g., "x, y = NULL, ..."
This method handles R-style defaults (like 1L, c(1,2,3)) that aren’t
valid Rust syntax by outputting them directly as strings.
Sourcepub fn build_call_args(&self) -> String
pub fn build_call_args(&self) -> String
Build R call arguments string (for .Call() invocation).
§Returns
Comma-separated argument list, e.g., "x, y, list(...)" (or
"x, y, environment()" for a LazyDots parameter)
Sourcepub fn build_call_args_vec(&self) -> Vec<String>
pub fn build_call_args_vec(&self) -> Vec<String>
Build R call arguments as a Vec<String>.
Each element is a single argument expression. A &Dots parameter
becomes "list(...)", which captures the variadic args as an R list for
the .Call() interface; a LazyDots parameter becomes
"environment()", the wrapper’s own frame, whose ... binding holds
the dots unforced (#1892).
Auto Trait Implementations§
impl<'a> !Send for RArgumentBuilder<'a>
impl<'a> !Sync for RArgumentBuilder<'a>
impl<'a> Freeze for RArgumentBuilder<'a>
impl<'a> RefUnwindSafe for RArgumentBuilder<'a>
impl<'a> Unpin for RArgumentBuilder<'a>
impl<'a> UnsafeUnpin for RArgumentBuilder<'a>
impl<'a> UnwindSafe for RArgumentBuilder<'a>
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: 176 bytes