Skip to main content

RArgumentBuilder

Struct RArgumentBuilder 

Source
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 (_xunused_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: bool

If 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: bool

If 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>

Source

pub fn new(inputs: &'a Punctuated<FnArg, Comma>) -> Self

Create a new builder for the given function inputs.

Source

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.

Source

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 ....

Source

pub fn skip_first(self) -> Self

Skip the first parameter (for instance methods with self).

Source

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.

Source

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(...)"

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

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