pub struct RArgumentBuilder<'a> {
inputs: &'a Punctuated<FnArg, Comma>,
has_dots: bool,
named_dots: Option<String>,
skip_first: bool,
defaults: HashMap<String, String>,
}Expand description
Builder for R function formal parameters and call arguments.
Handles:
- Underscore normalization (
_x→unused_x) - Unit type defaults (
()→= NULL) - Dots (
...) with optional naming - Consistent formatting across function and method wrappers
Fields§
§inputs: &'a Punctuated<FnArg, Comma>The function’s input parameters from the parsed Rust signature.
has_dots: boolIf true, last parameter is treated as dots (...).
named_dots: Option<String>Optional named binding for dots (e.g., args @ ... in Rust becomes a named dots param).
The name is normalized (leading underscores stripped) but only used on the Rust side;
R formals always emit plain ....
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 normalized R parameter names, values are R expressions emitted verbatim
(e.g., "1L", "c(1, 2, 3)", "NULL").
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_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 normalized R parameter names (after underscore stripping), values are R expression strings emitted verbatim into formals.
Sourcepub fn with_dots(self, named_dots: Option<String>) -> Self
pub fn with_dots(self, named_dots: Option<String>) -> Self
Mark the last parameter as dots (...).
If named_dots is Some("name"), the dots have a Rust-side binding
(from name @ ... syntax). The name is normalized but only affects the
Rust side – R formals always emit plain ....
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(...)"
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. Dots parameters become
"list(...)" to capture variadic args as an R list for the .Call() interface.
Auto Trait Implementations§
impl<'a> Freeze for RArgumentBuilder<'a>
impl<'a> RefUnwindSafe for RArgumentBuilder<'a>
impl<'a> !Send for RArgumentBuilder<'a>
impl<'a> !Sync 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> 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: 88 bytes