Skip to content

Commit 919649d

Browse files
committed
Fix clippy warnings
1 parent 553a585 commit 919649d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

hid-io-protocol/src/commands/test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2020-2021 by Jacob Alexander
1+
/* Copyright (C) 2020-2022 by Jacob Alexander
22
*
33
* Permission is hereby granted, free of charge, to any person obtaining a copy
44
* of this software and associated documentation files (the "Software"), to deal
@@ -29,6 +29,9 @@ use flexi_logger::Logger;
2929
#[cfg(feature = "server")]
3030
use log::debug;
3131

32+
#[cfg(feature = "device")]
33+
use defmt::{debug, error};
34+
3235
// ----- Enumerations -----
3336

3437
enum LogError {

hid-io-protocol/src/test.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2017-2021 by Jacob Alexander
1+
/* Copyright (C) 2017-2022 by Jacob Alexander
22
*
33
* Permission is hereby granted, free of charge, to any person obtaining a copy
44
* of this software and associated documentation files (the "Software"), to deal
@@ -54,21 +54,20 @@ fn loopback_serializer<const H: usize>(buffer: HidIoPacketBuffer<H>, data: &mut
5454
let data = match buffer.serialize_buffer(data) {
5555
Ok(data) => data,
5656
Err(err) => {
57-
assert!(false, "Serialized Buffer failed: {:?}", err);
58-
&[0u8; 0]
57+
panic!("Serialized Buffer failed: {:?}", err);
5958
}
6059
};
6160

6261
// Validate serialization worked
63-
assert!(data.len() > 0, "Serialization bytes:{}", data.len());
62+
assert!(!data.is_empty(), "Serialization bytes:{}", data.len());
6463

6564
// Deserialize while there are bytes left
6665
let mut deserialized = HidIoPacketBuffer::new();
6766
let mut bytes_used = 0;
6867
while bytes_used != data.len() {
6968
// Remove already processed bytes
7069
let slice = &data[bytes_used..];
71-
match deserialized.decode_packet(&mut slice.to_vec()) {
70+
match deserialized.decode_packet(slice) {
7271
Ok(result) => {
7372
bytes_used += result as usize;
7473
}
@@ -285,15 +284,13 @@ fn hid_vec2bitmask2vec_test() {
285284
let bitmask = match hid_vec2bitmask(&inputvec) {
286285
Ok(bitmask) => bitmask,
287286
Err(e) => {
288-
assert!(false, "Failed to run hid_vec2bitmask: {:?}", e);
289-
Vec::new()
287+
panic!("Failed to run hid_vec2bitmask: {:?}", e);
290288
}
291289
};
292290
let new_vec = match hid_bitmask2vec(&bitmask) {
293291
Ok(new_vec) => new_vec,
294292
Err(e) => {
295-
assert!(false, "Failed to run hid_bitmask2vec: {:?}", e);
296-
Vec::new()
293+
panic!("Failed to run hid_bitmask2vec: {:?}", e);
297294
}
298295
};
299296

0 commit comments

Comments
 (0)