From b6c87bd13aa4d8389972a9dd5526e1ca9c691cfc Mon Sep 17 00:00:00 2001 From: cgmossa Date: Sun, 21 Jan 2024 15:43:44 +0100 Subject: [PATCH] clippy: the closure might be too much --- extendr-api/src/scalar/rbool.rs | 10 +++++++++- extendr-api/src/scalar/rfloat.rs | 10 +++++++++- extendr-api/src/scalar/rint.rs | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/extendr-api/src/scalar/rbool.rs b/extendr-api/src/scalar/rbool.rs index 675f296870..e3c2ca79d2 100644 --- a/extendr-api/src/scalar/rbool.rs +++ b/extendr-api/src/scalar/rbool.rs @@ -60,7 +60,15 @@ impl Rbool { } } -gen_trait_impl!(Rbool, bool, |x: &Rbool| x.inner() == i32::MIN, i32::MIN); +mod rbool_helpers { + use super::*; + + pub fn check_na(x: &Rbool) -> bool { + x.inner() == i32::MIN + } +} + +gen_trait_impl!(Rbool, bool, rbool_helpers::check_na, i32::MIN); gen_from_primitive!(Rbool, i32); gen_partial_ord!(Rbool, bool); diff --git a/extendr-api/src/scalar/rfloat.rs b/extendr-api/src/scalar/rfloat.rs index 58fcfea93c..96e9408a71 100644 --- a/extendr-api/src/scalar/rfloat.rs +++ b/extendr-api/src/scalar/rfloat.rs @@ -84,9 +84,17 @@ impl Rfloat { } } +mod rfloat_helpers { + use super::*; + + pub fn check_na(x: &Rfloat) -> bool { + x.inner().is_na() + } +} + // `NA_real_` is a `NaN` with specific bit representation. // Check that underlying `f64` is `NA_real_`. -gen_trait_impl!(Rfloat, f64, |x: &Rfloat| x.inner().is_na(), f64::na()); +gen_trait_impl!(Rfloat, f64, rfloat_helpers::check_na, f64::na()); gen_from_primitive!(Rfloat, f64); impl From for Option { diff --git a/extendr-api/src/scalar/rint.rs b/extendr-api/src/scalar/rint.rs index 493bf705f9..55d2ff0c81 100644 --- a/extendr-api/src/scalar/rint.rs +++ b/extendr-api/src/scalar/rint.rs @@ -64,7 +64,15 @@ impl Rint { } } -gen_trait_impl!(Rint, i32, |x: &Rint| x.0 == i32::MIN, i32::MIN); +mod rint_helpers { + use super::*; + + pub fn check_na(x: &Rint) -> bool { + x.0 == i32::MIN + } +} + +gen_trait_impl!(Rint, i32, rint_helpers::check_na, i32::MIN); gen_from_primitive!(Rint, i32); impl From for Option {