From 177ddba9c55261a32dcd7700715a1fdbd9bf39ff Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 00:01:07 +0100 Subject: [PATCH] clippy fixes --- src/ecss.rs | 6 +++--- src/time/cds.rs | 7 +++---- src/time/cuc.rs | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ecss.rs b/src/ecss.rs index 47159d0..ea2896f 100644 --- a/src/ecss.rs +++ b/src/ecss.rs @@ -286,13 +286,13 @@ impl EcssEnumeration for GenericEcssEnumWrapper { } fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> { - if buf.len() < self.byte_width() as usize { + if buf.len() < self.byte_width() { return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch { found: buf.len(), - expected: self.byte_width() as usize, + expected: self.byte_width(), })); } - buf[0..self.byte_width() as usize].copy_from_slice(self.val.to_be_bytes().as_ref()); + buf[0..self.byte_width()].copy_from_slice(self.val.to_be_bytes().as_ref()); Ok(()) } } diff --git a/src/time/cds.rs b/src/time/cds.rs index dd88215..b22015b 100644 --- a/src/time/cds.rs +++ b/src/time/cds.rs @@ -338,9 +338,8 @@ impl TimeProvider { unix_seconds: 0, submillis_precision: None, }; - let unix_days_seconds = - ccsds_to_unix_days(ccsds_days.into()) as i64 * SECONDS_PER_DAY as i64; - provider.setup(unix_days_seconds as i64, ms_of_day.into()); + let unix_days_seconds = ccsds_to_unix_days(ccsds_days.into()) * SECONDS_PER_DAY as i64; + provider.setup(unix_days_seconds, ms_of_day.into()); Ok(provider) } @@ -552,7 +551,7 @@ impl CcsdsTimeProvider for TimeProvider Option> { - self.calc_date_time((self.ms_of_day % 1000) as u32) + self.calc_date_time(self.ms_of_day % 1000) } } diff --git a/src/time/cuc.rs b/src/time/cuc.rs index 9ccd439..7347921 100644 --- a/src/time/cuc.rs +++ b/src/time/cuc.rs @@ -206,7 +206,7 @@ impl TimeProviderCcsdsEpoch { WidthCounterPair(4, counter), Some(FractionalPart( FractionalResolution::SixtyNs, - subsec_fractions as u32, + subsec_fractions, )), ) } @@ -431,9 +431,9 @@ impl TimeReader for TimeProviderCcsdsEpoch { 3 => { let mut tmp_buf: [u8; 4] = [0; 4]; tmp_buf[1..4].copy_from_slice(&buf[current_idx..current_idx + 3]); - u32::from_be_bytes(tmp_buf) as u32 + u32::from_be_bytes(tmp_buf) } - 4 => u32::from_be_bytes(buf[current_idx..current_idx + 4].try_into().unwrap()) as u32, + 4 => u32::from_be_bytes(buf[current_idx..current_idx + 4].try_into().unwrap()), _ => panic!("unreachable match arm"), }; current_idx += cntr_len as usize; @@ -458,7 +458,7 @@ impl TimeReader for TimeProviderCcsdsEpoch { tmp_buf[1..4].copy_from_slice(&buf[current_idx..current_idx + 3]); fractions = Some(FractionalPart( fractions_len.try_into().unwrap(), - u32::from_be_bytes(tmp_buf) as u32, + u32::from_be_bytes(tmp_buf), )) } _ => panic!("unreachable match arm"),