Skip to main content

check_rng_seed

Function check_rng_seed 

Source
pub(crate) fn check_rng_seed(
    seed: &Ident,
    all_inputs: &Punctuated<FnArg, Comma>,
    r_inputs: &Punctuated<FnArg, Comma>,
    formals: &Formals,
    unevaluated: &[String],
    unit_return: bool,
) -> Result<String>
Expand description

Check rng(seed = <param>) (#2198) against a standalone function’s signature and return the seed’s R formal. Every problem is reported at once:

  • seed names a parameter of all_inputs, by its Rust name;
  • the parameter is an R argument the wrapper evaluates: one of the formals of r_inputs (the signature without the condition-call marker and the RNG guard), not ..., an NArgs or a Quoted / Quosure argument (unevaluated, by R name), since set.seed() forces it;
  • the return can carry the seed attribute: a unit return (unit_return) is NULL, which has none.

The R name comes from the formal list (r_formal_names with formals), so the prelude names the formal the wrapper has, a declared formal included (#1842).