Skip to main content

get_option

Function get_option 

Source
pub fn get_option<T>(name: &str) -> Result<Option<T>, RError>
Expand description

Read the R option name, as getOption(name) does, and convert it to T.

Ok(None) when the option is unset or set to NULL (R does not tell the two apart). A value that doesn’t convert is an error: its message names options("name") and gives the conversion’s reason in R terms, its class is OPTION_ERROR_CLASS (after the classes of a refusal that carries its own, such as a #[try_from_sexp(validate = ...)] check), and e$option is name.

Read into an owned T (String, Vec<_>, …). A borrowed T such as &str points into the option’s value, which nothing roots once this returns: options(name = NULL) or a new value lets R free it.

§Panics

Off R’s main thread, before reading anything.