Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Gherghescu <[email protected]>
  • Loading branch information
andrei-ng committed Dec 23, 2024
1 parent d6f4804 commit 63dfdaf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions ublox/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl UnderlyingBuffer for Vec<u8> {
}

fn max_capacity(&self) -> usize {
core::usize::MAX
usize::MAX
}

fn extend_from_slice(&mut self, other: &[u8]) -> usize {
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<'a> FixedLinearBuffer<'a> {
}
}

impl<'a> core::ops::Index<core::ops::Range<usize>> for FixedLinearBuffer<'a> {
impl core::ops::Index<core::ops::Range<usize>> for FixedLinearBuffer<'_> {
type Output = [u8];

fn index(&self, index: core::ops::Range<usize>) -> &Self::Output {
Expand All @@ -104,15 +104,15 @@ impl<'a> core::ops::Index<core::ops::Range<usize>> for FixedLinearBuffer<'a> {
}
}

impl<'a> core::ops::Index<usize> for FixedLinearBuffer<'a> {
impl core::ops::Index<usize> for FixedLinearBuffer<'_> {
type Output = u8;

fn index(&self, index: usize) -> &Self::Output {
&self.buffer[index]
}
}

impl<'a> UnderlyingBuffer for FixedLinearBuffer<'a> {
impl UnderlyingBuffer for FixedLinearBuffer<'_> {
fn clear(&mut self) {
self.len = 0;
}
Expand Down Expand Up @@ -213,7 +213,7 @@ struct DualBuffer<'a, T: UnderlyingBuffer> {
new_buf_offset: usize,
}

impl<'a, T: UnderlyingBuffer> core::ops::Index<usize> for DualBuffer<'a, T> {
impl<T: UnderlyingBuffer> core::ops::Index<usize> for DualBuffer<'_, T> {
type Output = u8;

fn index(&self, index: usize) -> &u8 {
Expand Down Expand Up @@ -375,7 +375,7 @@ impl<'a, T: UnderlyingBuffer> DualBuffer<'a, T> {
}
}

impl<'a, T: UnderlyingBuffer> Drop for DualBuffer<'a, T> {
impl<T: UnderlyingBuffer> Drop for DualBuffer<'_, T> {
fn drop(&mut self) {
self.buf.drain(self.off);
self.buf
Expand Down Expand Up @@ -416,7 +416,7 @@ pub struct ParserIter<'a, T: UnderlyingBuffer> {
buf: DualBuffer<'a, T>,
}

impl<'a, T: UnderlyingBuffer> ParserIter<'a, T> {
impl<T: UnderlyingBuffer> ParserIter<'_, T> {
fn find_sync(&self) -> Option<usize> {
(0..self.buf.len()).find(|&i| self.buf[i] == SYNC_CHAR_1)
}
Expand Down
40 changes: 20 additions & 20 deletions ublox/src/ubx_packets/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ struct AckAck {
msg_id: u8,
}

impl<'a> AckAckRef<'a> {
impl AckAckRef<'_> {
pub fn is_ack_for<T: UbxPacketMeta>(&self) -> bool {
self.class() == T::CLASS && self.msg_id() == T::ID
}
Expand All @@ -1312,7 +1312,7 @@ struct AckNak {
msg_id: u8,
}

impl<'a> AckNakRef<'a> {
impl AckNakRef<'_> {
pub fn is_nak_for<T: UbxPacketMeta>(&self) -> bool {
self.class() == T::CLASS && self.msg_id() == T::ID
}
Expand Down Expand Up @@ -1799,7 +1799,7 @@ impl<'a> CfgValIter<'a> {
}
}

impl<'a> core::iter::Iterator for CfgValIter<'a> {
impl core::iter::Iterator for CfgValIter<'_> {
type Item = CfgVal;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -2395,21 +2395,21 @@ struct ScaleBack<T: FloatCore + FromPrimitive + ToPrimitive>(T);
impl<T: FloatCore + FromPrimitive + ToPrimitive> ScaleBack<T> {
fn as_i8(self, x: T) -> i8 {
let x = (x * self.0).round();
if x < T::from_i8(i8::min_value()).unwrap() {
i8::min_value()
} else if x > T::from_i8(i8::max_value()).unwrap() {
i8::max_value()
if x < T::from_i8(i8::MIN).unwrap() {
i8::MIN
} else if x > T::from_i8(i8::MAX).unwrap() {
i8::MAX
} else {
x.to_i8().unwrap()
}
}

fn as_i16(self, x: T) -> i16 {
let x = (x * self.0).round();
if x < T::from_i16(i16::min_value()).unwrap() {
i16::min_value()
} else if x > T::from_i16(i16::max_value()).unwrap() {
i16::max_value()
if x < T::from_i16(i16::MIN).unwrap() {
i16::MIN
} else if x > T::from_i16(i16::MAX).unwrap() {
i16::MAX
} else {
x.to_i16().unwrap()
}
Expand Down Expand Up @@ -3155,7 +3155,7 @@ impl EsfMeas {
}
}

impl<'a> EsfMeasRef<'a> {
impl EsfMeasRef<'_> {
fn data_len(&self) -> usize {
self.flags().num_meas() as usize * 4
}
Expand Down Expand Up @@ -3239,7 +3239,7 @@ impl<'a> EsfMeasDataIter<'a> {
}
}

impl<'a> core::iter::Iterator for EsfMeasDataIter<'a> {
impl core::iter::Iterator for EsfMeasDataIter<'_> {
type Item = EsfMeasData;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -3252,7 +3252,7 @@ impl<'a> core::iter::Iterator for EsfMeasDataIter<'a> {
}

Some(EsfMeasData {
data_type: (((data & 0x3F000000) >> 24) as u8).try_into().unwrap(),
data_type: (((data & 0x3F000000) >> 24) as u8).into(),
data_field,
})
}
Expand Down Expand Up @@ -3343,7 +3343,7 @@ impl<'a> EsfRawDataIter<'a> {
}
}

impl<'a> core::iter::Iterator for EsfRawDataIter<'a> {
impl core::iter::Iterator for EsfRawDataIter<'_> {
type Item = EsfRawData;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -3659,17 +3659,17 @@ impl<'a> EsfStatusDataIter<'a> {
}
}

impl<'a> core::iter::Iterator for EsfStatusDataIter<'a> {
impl core::iter::Iterator for EsfStatusDataIter<'_> {
type Item = EsfStatusData;

fn next(&mut self) -> Option<Self::Item> {
let chunk = self.0.next()?;
let data = u32::from_le_bytes(chunk[0..4].try_into().unwrap());
Some(EsfStatusData {
sens_status1: ((data & 0xFF) as u8).try_into().unwrap(),
sens_status2: (((data >> 8) & 0xFF) as u8).try_into().unwrap(),
sens_status1: ((data & 0xFF) as u8).into(),
sens_status2: (((data >> 8) & 0xFF) as u8).into(),
freq: ((data >> 16) & 0xFF).try_into().unwrap(),
faults: (((data >> 24) & 0xFF) as u8).try_into().unwrap(),
faults: (((data >> 24) & 0xFF) as u8).into(),
})
}
}
Expand Down Expand Up @@ -4024,7 +4024,7 @@ impl<'a> DwrdIter<'a> {
}
}

impl<'a> core::iter::Iterator for DwrdIter<'a> {
impl core::iter::Iterator for DwrdIter<'_> {
type Item = u32;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion ublox_derive/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ pub fn generate_code_to_extend_enum(ubx_enum: &UbxExtendEnum) -> TokenStream {
let attrs = &ubx_enum.attrs;
if let Some(UbxEnumRestHandling::Reserved) = ubx_enum.rest_handling {
let defined: HashSet<u8> = ubx_enum.variants.iter().map(|x| x.1).collect();
for i in 0..=u8::max_value() {
for i in 0..=u8::MAX {
if !defined.contains(&i) {
let name = format_ident!("Reserved{}", i);
variants.push((name, i));
Expand Down

0 comments on commit 63dfdaf

Please sign in to comment.