Skip to content

Commit

Permalink
clippy: the closure might be too much
Browse files Browse the repository at this point in the history
  • Loading branch information
CGMossa committed Jan 21, 2024
1 parent c0726a0 commit b6c87bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 9 additions & 1 deletion extendr-api/src/scalar/rbool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 9 additions & 1 deletion extendr-api/src/scalar/rfloat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rfloat> for Option<f64> {
Expand Down
10 changes: 9 additions & 1 deletion extendr-api/src/scalar/rint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rint> for Option<i32> {
Expand Down

0 comments on commit b6c87bd

Please sign in to comment.