Skip to content

Commit b731193

Browse files
committed
fix clippy errors
fix all errors reported by `cargo clippy`.
1 parent 1494a8b commit b731193

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/bluefruit_protocol/button_event.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Button {
3232
b'6' => Ok(Button::Down),
3333
b'7' => Ok(Button::Left),
3434
b'8' => Ok(Button::Right),
35-
_ => Err(ButtonParseError::UnknownButton(input.clone())),
35+
_ => Err(ButtonParseError::UnknownButton(*input)),
3636
}
3737
}
3838
}
@@ -50,7 +50,7 @@ impl ButtonState {
5050
match input {
5151
b'0' => Ok(ButtonState::Released),
5252
b'1' => Ok(ButtonState::Pressed),
53-
_ => Err(ButtonParseError::UnknownButtonState(input.clone())),
53+
_ => Err(ButtonParseError::UnknownButtonState(*input)),
5454
}
5555
}
5656
}
@@ -74,10 +74,9 @@ impl TryFrom<&[u8]> for ButtonEvent {
7474
Err(ProtocolParseError::InvalidLength(expected_len, input.len()))
7575
} else {
7676
Ok(ButtonEvent {
77-
button: Button::from_id(&input[0])
78-
.map_err(|e| ProtocolParseError::ButtonParseError(e))?,
77+
button: Button::from_id(&input[0]).map_err(ProtocolParseError::ButtonParseError)?,
7978
state: ButtonState::from_id(&input[1])
80-
.map_err(|e| ProtocolParseError::ButtonParseError(e))?,
79+
.map_err(ProtocolParseError::ButtonParseError)?,
8180
})
8281
}
8382
}

src/bluefruit_protocol/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub const MAX_CONTROLLER_MESSAGE_LENGTH: usize = 32; // give slightly more than
6161

6262
impl ControllerDataPackageType {
6363
/// Returns the length of the data section of the command.
64-
fn data_len(self: &Self) -> usize {
64+
fn data_len(&self) -> usize {
6565
match self {
6666
ControllerDataPackageType::ButtonCommand => 2,
6767
ControllerDataPackageType::Color => 3,
@@ -123,7 +123,7 @@ pub fn parse<const MAX_RESULTS: usize>(
123123
};
124124
}
125125

126-
return result;
126+
result
127127
}
128128

129129
/// Extract a command and then try to parse it.
@@ -162,25 +162,25 @@ fn parse_command(
162162
let data = &command_input[data_start..=data_end];
163163
match command {
164164
ControllerDataPackageType::ButtonCommand => {
165-
ButtonEvent::try_from(data).map(|evt| ControllerEvent::ButtonEvent(evt))
165+
ButtonEvent::try_from(data).map(ControllerEvent::ButtonEvent)
166166
}
167167
ControllerDataPackageType::Color => {
168-
ColorEvent::try_from(data).map(|evt| ControllerEvent::ColorEvent(evt))
168+
ColorEvent::try_from(data).map(ControllerEvent::ColorEvent)
169169
}
170170
ControllerDataPackageType::Quaternion => {
171-
QuaternionEvent::try_from(data).map(|evt| ControllerEvent::QuaternionEvent(evt))
171+
QuaternionEvent::try_from(data).map(ControllerEvent::QuaternionEvent)
172172
}
173173
ControllerDataPackageType::Accelerometer => {
174-
AccelerometerEvent::try_from(data).map(|evt| ControllerEvent::AccelerometerEvent(evt))
174+
AccelerometerEvent::try_from(data).map(ControllerEvent::AccelerometerEvent)
175175
}
176176
ControllerDataPackageType::Gyro => {
177-
GyroEvent::try_from(data).map(|evt| ControllerEvent::GyroEvent(evt))
177+
GyroEvent::try_from(data).map(ControllerEvent::GyroEvent)
178178
}
179179
ControllerDataPackageType::Magnetometer => {
180-
MagnetometerEvent::try_from(data).map(|evt| ControllerEvent::MagnetometerEvent(evt))
180+
MagnetometerEvent::try_from(data).map(ControllerEvent::MagnetometerEvent)
181181
}
182182
ControllerDataPackageType::Location => {
183-
LocationEvent::try_from(data).map(|evt| ControllerEvent::LocationEvent(evt))
183+
LocationEvent::try_from(data).map(ControllerEvent::LocationEvent)
184184
}
185185
}
186186
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl BluefruitLEUARTFriend {
4343
serial::Config::default()
4444
.baudrate(9600.bps())
4545
.dma(serial::config::DmaConfig::Rx),
46-
&clocks,
46+
clocks,
4747
)
4848
.expect("USART1 can be set up");
4949

0 commit comments

Comments
 (0)