Skip to main content

no_na_checked_after_conversion

Function no_na_checked_after_conversion 

Source
pub(crate) fn no_na_checked_after_conversion(ty: &Type) -> bool
Expand description

Whether a no_na parameter of Rust type ty is checked for NA only in Rust, after the conversion, with no R guard: an Either<L, R>, also under Missing and Option. The layers are peeled as for a choice parameter (crate::type_inspect::choice_layers). A plain Option<Either<..>> converts through TryFromSexp, which reads NULL as None (no NA) and asks the Either otherwise; a choice Option<Either<Mode, X>> keeps the guard (see below). The type is read as written: an alias, a newtype or a Result<Either<..>, ()> keeps the guard.

One !anyNA(x) on the whole argument is wrong for an arm with its own reading of NA (a data frame arm whose cells may be missing), and it scans the input a second time. So the C wrapper asks the arm the value converted to (TryFromSexp::__mx_input_has_na): by default the arm runs anyNA()’s check on the input in Rust, and a DataFrame arm refuses nothing. A choice parameter (match_arg / choices) keeps the R guard: its conversion does not go through TryFromSexp, so no Rust check follows.