Skip to content

Commit 727d8df

Browse files
authored
fix new clippy lints (#389)
1 parent 86a4d01 commit 727d8df

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

hal/src/subghz/mod_params.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl Ord for FskBandwidth {
170170

171171
impl PartialOrd for FskBandwidth {
172172
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
173-
Some(self.hertz().cmp(&other.hertz()))
173+
Some(self.cmp(other))
174174
}
175175
}
176176

@@ -278,7 +278,7 @@ impl Ord for FskBitrate {
278278

279279
impl PartialOrd for FskBitrate {
280280
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
281-
Some(self.as_bps().cmp(&other.as_bps()))
281+
Some(self.cmp(other))
282282
}
283283
}
284284

@@ -711,7 +711,7 @@ impl Ord for LoRaBandwidth {
711711

712712
impl PartialOrd for LoRaBandwidth {
713713
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
714-
Some(self.hertz().cmp(&other.hertz()))
714+
Some(self.cmp(other))
715715
}
716716
}
717717

@@ -752,7 +752,6 @@ pub enum CodingRate {
752752
/// LoRa modulation parameters.
753753
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
754754
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
755-
756755
pub struct LoRaModParams {
757756
buf: [u8; 5],
758757
}

hal/src/subghz/timeout.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ use core::time::Duration;
22

33
use super::ValueError;
44

5-
const fn abs_diff(a: u64, b: u64) -> u64 {
6-
if a > b { a - b } else { b - a }
7-
}
8-
95
/// Timeout argument.
106
///
117
/// This is used by:
@@ -159,8 +155,8 @@ impl Timeout {
159155
let timeout_ceil: Timeout = Timeout::from_raw(div_ceil as u32);
160156
let timeout_floor: Timeout = Timeout::from_raw(div_floor as u32);
161157

162-
let error_ceil: u64 = abs_diff(timeout_ceil.as_nanos(), duration_nanos);
163-
let error_floor: u64 = abs_diff(timeout_floor.as_nanos(), duration_nanos);
158+
let error_ceil: u64 = timeout_ceil.as_nanos().abs_diff(duration_nanos);
159+
let error_floor: u64 = timeout_floor.as_nanos().abs_diff(duration_nanos);
164160

165161
if error_ceil < error_floor {
166162
Ok(timeout_ceil)
@@ -221,8 +217,8 @@ impl Timeout {
221217
let timeout_ceil: Timeout = Timeout::from_raw(div_ceil as u32);
222218
let timeout_floor: Timeout = Timeout::from_raw(div_floor as u32);
223219

224-
let error_ceil: u64 = abs_diff(timeout_ceil.as_nanos(), duration_nanos);
225-
let error_floor: u64 = abs_diff(timeout_floor.as_nanos(), duration_nanos);
220+
let error_ceil: u64 = timeout_ceil.as_nanos().abs_diff(duration_nanos);
221+
let error_floor: u64 = timeout_floor.as_nanos().abs_diff(duration_nanos);
226222

227223
if error_ceil < error_floor {
228224
timeout_ceil

0 commit comments

Comments
 (0)