summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-07-08 12:25:31 +0200
committerRobin Krahl <robin.krahl@ireas.org>2020-07-08 23:02:43 +0200
commitcf460cbb5e616d12f5e6b1f64acddf3ec0e7b087 (patch)
treea5cf3855f963d0417d9af8243b820fcaee2c896c /src/device
parent9f80512a11926c5ec3f869ad5e220b3b350eec9a (diff)
downloadnitrokey-rs-cf460cbb5e616d12f5e6b1f64acddf3ec0e7b087.tar.gz
nitrokey-rs-cf460cbb5e616d12f5e6b1f64acddf3ec0e7b087.tar.bz2
Use find(…) instead of skip_while(…).next()
This patch replaces calls to skip_while(…).next() for an iter::Iterator with a call to find(…), as suggested by clippy.
Diffstat (limited to 'src/device')
-rw-r--r--src/device/mod.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/device/mod.rs b/src/device/mod.rs
index 5082537..c84faa1 100644
--- a/src/device/mod.rs
+++ b/src/device/mod.rs
@@ -223,9 +223,8 @@ fn get_hidapi_serial_number(serial_number: &str) -> Option<SerialNumber> {
return None;
}
- let iter = serial_number.char_indices().rev();
- let first_non_null = iter.skip_while(|(_, c)| *c == '0').next();
- if let Some((i, _)) = first_non_null {
+ let mut iter = serial_number.char_indices().rev();
+ if let Some((i, _)) = iter.find(|(_, c)| *c != '0') {
let substr = if len - i < 8 {
// The last eight characters contain at least one non-zero character --> use them
serial_number.split_at(len - 8).1