From 9f80512a11926c5ec3f869ad5e220b3b350eec9a Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 8 Jul 2020 12:18:41 +0200 Subject: Remove unused imports --- src/device/mod.rs | 2 -- src/device/pro.rs | 2 -- src/device/storage.rs | 2 -- 3 files changed, 6 deletions(-) (limited to 'src/device') diff --git a/src/device/mod.rs b/src/device/mod.rs index 067fdf6..5082537 100644 --- a/src/device/mod.rs +++ b/src/device/mod.rs @@ -10,8 +10,6 @@ use std::ffi; use std::fmt; use std::str; -use nitrokey_sys; - use crate::auth::Authenticate; use crate::config::{Config, RawConfig}; use crate::error::{CommunicationError, Error, LibraryError}; diff --git a/src/device/pro.rs b/src/device/pro.rs index 591b730..0d5443e 100644 --- a/src/device/pro.rs +++ b/src/device/pro.rs @@ -1,8 +1,6 @@ // Copyright (C) 2018-2019 Robin Krahl // SPDX-License-Identifier: MIT -use nitrokey_sys; - use crate::device::{Device, Model, Status}; use crate::error::Error; use crate::otp::GenerateOtp; diff --git a/src/device/storage.rs b/src/device/storage.rs index 5669a91..a18d94f 100644 --- a/src/device/storage.rs +++ b/src/device/storage.rs @@ -5,8 +5,6 @@ use std::convert::TryFrom as _; use std::fmt; use std::ops; -use nitrokey_sys; - use crate::device::{Device, FirmwareVersion, Model, SerialNumber, Status}; use crate::error::{CommandError, Error}; use crate::otp::GenerateOtp; -- cgit v1.2.3 From cf460cbb5e616d12f5e6b1f64acddf3ec0e7b087 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 8 Jul 2020 12:25:31 +0200 Subject: Use find(…) instead of skip_while(…).next() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch replaces calls to skip_while(…).next() for an iter::Iterator with a call to find(…), as suggested by clippy. --- src/device/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/device') 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 { 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 -- cgit v1.2.3