Skip to main content

FromArgs

Trait FromArgs 

Source
pub trait FromArgs: Sized {
    // Required methods
    fn from_args(
        args: &[RValue],
        named: &[(String, RValue)],
    ) -> Result<Self, RError>;
    fn info() -> &'static BuiltinInfo;
}
Expand description

Decode R call arguments into a typed struct.

Implemented by #[derive(FromArgs)] on structs whose fields represent R function parameters. Field names become R parameter names, field types determine coercion, and #[default(...)] marks optional parameters.

Field type determines behavior:

  • T — required, error if missing
  • Option<T> — optional, None if missing
  • RArg<T> — three-way: Missing / Null / Value
  • Dots — captures remaining positional args

Required Methods§

Source

fn from_args( args: &[RValue], named: &[(String, RValue)], ) -> Result<Self, RError>

Decode positional and named R arguments into Self.

Source

fn info() -> &'static BuiltinInfo

Static metadata: parameter count, names, docs.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§