From 703ece9ffa67d13b79f67054b1a85e8035b44e0f Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 26 Dec 2023 11:54:08 +0100 Subject: [PATCH] Fix clippy warnings --- .github/workflows/ci.yml | 4 ++-- src/types.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8ee7d2..1c1a820 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@1.74.1 with: components: clippy - - run: cargo clippy --all-features + - run: cargo clippy --all-features -- -D warnings rustfmt: name: Rustfmt diff --git a/src/types.rs b/src/types.rs index 4c4f60e..6d240dc 100644 --- a/src/types.rs +++ b/src/types.rs @@ -78,7 +78,7 @@ impl Humidity { return Err(HumidityError::OutOfRange); } - let integer = if val >= 256.0 || val < 0.0 { + let integer = if !(0.0..256.0).contains(&val) { return Err(HumidityError::OutOfRange); } else { val.trunc() as u8 @@ -103,10 +103,10 @@ impl Humidity { } } -impl Into for Humidity { +impl From for f32 { /// Convert a `Humidity` instance to a f32. - fn into(self) -> f32 { - f32::from(self.integer) + (f32::from(self.fractional) / 256.0) + fn from(val: Humidity) -> Self { + f32::from(val.integer) + (f32::from(val.fractional) / 256.0) } }