Skip to content

Commit

Permalink
Merge pull request #495 from nyurik/clippy
Browse files Browse the repository at this point in the history
A few clippy lint fixes
  • Loading branch information
Dirbaio authored Sep 1, 2023
2 parents 81b70d3 + 3005247 commit 8480a33
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
7 changes: 7 additions & 0 deletions embedded-can/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl StandardId {
///
/// This will return `None` if `raw` is out of range of an 11-bit integer (`> 0x7FF`).
#[inline]
#[must_use]
pub const fn new(raw: u16) -> Option<Self> {
if raw <= 0x7FF {
Some(Self(raw))
Expand All @@ -28,12 +29,14 @@ impl StandardId {
/// # Safety
/// Using this method can create an invalid ID and is thus marked as unsafe.
#[inline]
#[must_use]
pub const unsafe fn new_unchecked(raw: u16) -> Self {
Self(raw)
}

/// Returns this CAN Identifier as a raw 16-bit integer.
#[inline]
#[must_use]
pub const fn as_raw(&self) -> u16 {
self.0
}
Expand All @@ -54,6 +57,7 @@ impl ExtendedId {
///
/// This will return `None` if `raw` is out of range of an 29-bit integer (`> 0x1FFF_FFFF`).
#[inline]
#[must_use]
pub const fn new(raw: u32) -> Option<Self> {
if raw <= 0x1FFF_FFFF {
Some(Self(raw))
Expand All @@ -67,17 +71,20 @@ impl ExtendedId {
/// # Safety
/// Using this method can create an invalid ID and is thus marked as unsafe.
#[inline]
#[must_use]
pub const unsafe fn new_unchecked(raw: u32) -> Self {
Self(raw)
}

/// Returns this CAN Identifier as a raw 32-bit integer.
#[inline]
#[must_use]
pub const fn as_raw(&self) -> u32 {
self.0
}

/// Returns the Base ID part of this extended identifier.
#[must_use]
pub fn standard_id(&self) -> StandardId {
// ID-28 to ID-18
StandardId((self.0 >> 18) as u16)
Expand Down
4 changes: 2 additions & 2 deletions embedded-hal-async/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ where
{
#[inline]
async fn delay_us(&mut self, us: u32) {
T::delay_us(self, us).await
T::delay_us(self, us).await;
}

#[inline]
async fn delay_ms(&mut self, ms: u32) {
T::delay_ms(self, ms).await
T::delay_ms(self, ms).await;
}
}
4 changes: 2 additions & 2 deletions embedded-hal/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ where
{
#[inline]
fn delay_us(&mut self, us: u32) {
T::delay_us(self, us)
T::delay_us(self, us);
}

#[inline]
fn delay_ms(&mut self, ms: u32) {
T::delay_ms(self, ms)
T::delay_ms(self, ms);
}
}
8 changes: 4 additions & 4 deletions embedded-io-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ pub trait Read: ErrorType {
Err(e) => return Err(ReadExactError::Other(e)),
}
}
if !buf.is_empty() {
Err(ReadExactError::UnexpectedEof)
} else {
if buf.is_empty() {
Ok(())
} else {
Err(ReadExactError::UnexpectedEof)
}
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ impl<T: ?Sized + BufRead> BufRead for &mut T {
}

fn consume(&mut self, amt: usize) {
T::consume(self, amt)
T::consume(self, amt);
}
}

Expand Down
8 changes: 4 additions & 4 deletions embedded-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ pub trait Read: ErrorType {
Err(e) => return Err(ReadExactError::Other(e)),
}
}
if !buf.is_empty() {
Err(ReadExactError::UnexpectedEof)
} else {
if buf.is_empty() {
Ok(())
} else {
Err(ReadExactError::UnexpectedEof)
}
}
}
Expand Down Expand Up @@ -535,7 +535,7 @@ impl<T: ?Sized + BufRead> BufRead for &mut T {
}

fn consume(&mut self, amt: usize) {
T::consume(self, amt)
T::consume(self, amt);
}
}

Expand Down

0 comments on commit 8480a33

Please sign in to comment.