Skip to content

Commit 9327d97

Browse files
committed
Fix cargo clippy feedback.
1 parent a4d6a58 commit 9327d97

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

src/backend/semtech_udp/structs.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,10 @@ impl PullResp {
677677
timestamp.copy_from_slice(&tx_info.context[0..4]);
678678
let mut timestamp = u32::from_be_bytes(timestamp);
679679

680-
let delay = v
680+
let delay = *v
681681
.delay
682682
.as_ref()
683-
.ok_or_else(|| anyhow!("delay is missing"))?
684-
.clone();
683+
.ok_or_else(|| anyhow!("delay is missing"))?;
685684
let delay: Duration = delay.try_into()?;
686685
timestamp += delay.as_micros() as u32;
687686
Some(timestamp)
@@ -690,11 +689,10 @@ impl PullResp {
690689
},
691690
tmms: match timing_params {
692691
gw::timing::Parameters::GpsEpoch(v) => {
693-
let gps_time = v
692+
let gps_time = *v
694693
.time_since_gps_epoch
695694
.as_ref()
696-
.ok_or_else(|| anyhow!("time_since_gps_epoch is missing"))?
697-
.clone();
695+
.ok_or_else(|| anyhow!("time_since_gps_epoch is missing"))?;
698696
let gps_time: Duration = gps_time.try_into()?;
699697
Some(gps_time.as_millis() as u64)
700698
}

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ mod test {
119119

120120
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
121121

122-
assert_eq!(false, fs::exists(&temp_file).unwrap());
122+
assert!(!fs::exists(&temp_file).unwrap());
123123
}
124124

125125
#[tokio::test]

tests/concentratord_test.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ async fn end_to_end() {
5050
tokio::spawn({
5151
async move {
5252
loop {
53-
match eventloop.poll().await {
54-
Ok(v) => match v {
55-
Event::Incoming(Incoming::Publish(p)) => mqtt_tx.send(p).await.unwrap(),
56-
_ => {}
57-
},
58-
Err(_) => {}
53+
if let Ok(v) = eventloop.poll().await {
54+
if let Event::Incoming(Incoming::Publish(p)) = v {
55+
mqtt_tx.send(p).await.unwrap()
56+
}
5957
}
6058
}
6159
}

tests/semtech_udp_test.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ async fn end_to_end() {
5656
tokio::spawn({
5757
async move {
5858
loop {
59-
match eventloop.poll().await {
60-
Ok(v) => match v {
61-
Event::Incoming(Incoming::Publish(p)) => mqtt_tx.send(p).await.unwrap(),
62-
_ => {}
63-
},
64-
Err(_) => {}
59+
if let Ok(v) = eventloop.poll().await {
60+
if let Event::Incoming(Incoming::Publish(p)) = v {
61+
mqtt_tx.send(p).await.unwrap()
62+
}
6563
}
6664
}
6765
}
@@ -139,7 +137,7 @@ async fn end_to_end() {
139137
.unwrap()
140138
.with_timezone(&Utc);
141139
let mut b = vec![2, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8];
142-
b.extend_from_slice(&mut pl_b.as_bytes());
140+
b.extend_from_slice(pl_b.as_bytes());
143141
socket.send(&b).await.unwrap();
144142

145143
// PUSH_ACK
@@ -171,7 +169,7 @@ async fn end_to_end() {
171169
}),
172170
rx_info: Some(gw::UplinkRxInfo {
173171
gateway_id: "0102030405060708".into(),
174-
gw_time: Some(pbjson_types::Timestamp::from(ts.clone())),
172+
gw_time: Some(pbjson_types::Timestamp::from(ts)),
175173
rssi: -35,
176174
snr: 5.1,
177175
channel: 2,
@@ -272,7 +270,7 @@ async fn end_to_end() {
272270
}
273271
}"#;
274272
let mut b = vec![2, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8];
275-
b.extend_from_slice(&mut pl_b.as_bytes());
273+
b.extend_from_slice(pl_b.as_bytes());
276274
socket.send(&b).await.unwrap();
277275

278276
// PUSH_ACK

0 commit comments

Comments
 (0)