Skip to content

Commit

Permalink
clippy improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
metasophiea committed Sep 30, 2024
1 parent e5aebfc commit 4b9769a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "firmata-client-rs"
version = "0.4.2"
version = "0.4.3"
license = "MIT OR Apache-2.0"
authors = ["Brandon Walsh <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/board/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ use crate::types::{
let port = (pin/8) as usize;

if let Some(pin) = self.pins.get_mut(pin as usize) {
pin.value = if level { 1 } else { 0 };
pin.value = u8::from(level);
} else {
return Err(Error::PinOutOfBounds { pin, len: self.pins.len() })
}
Expand Down
2 changes: 1 addition & 1 deletion src/board/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl Board {
// channel info into local data
let mut pin_updates:Vec<(u8, bool)> = vec![];

for index in 0..8 as u8 {
for index in 0..8u8 {
let pin_index = (8 * port) + index;

if let Some(pin) = self.pins.get_mut(pin_index as usize) {
Expand Down
2 changes: 2 additions & 0 deletions src/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ pub enum Message {
}

impl Message {
#[must_use]
pub fn try_as_analog(&self) -> Option<&Vec<(u8, u8)>> {
if let Message::Analog(data) = self {
Some(data)
} else {
None
}
}
#[must_use]
pub fn try_as_digital(&self) -> Option<&Vec<(u8, bool)>> {
if let Message::Digital(data) = self {
Some(data)
Expand Down

0 comments on commit 4b9769a

Please sign in to comment.