clippy fixes

This commit is contained in:
Jack Grigg
2021-04-15 22:22:07 +12:00
parent 9208719e8c
commit f05c635d7b
2 changed files with 7 additions and 13 deletions
+1 -6
View File
@@ -291,12 +291,7 @@ fn main() -> Result<(), Error> {
eprintln!("make your choice, or press [Esc] or [q] to quit.");
eprintln!();
if Readers::open()?
.iter()?
.filter(yubikey::filter_connected)
.next()
.is_none()
{
if !Readers::open()?.iter()?.any(yubikey::is_connected) {
eprintln!("⏳ Please insert the YubiKey you want to set up.");
};
let mut readers = yubikey::wait_for_readers()?;
+6 -7
View File
@@ -33,6 +33,10 @@ use crate::{
const ONE_SECOND: Duration = Duration::from_secs(1);
const FIFTEEN_SECONDS: Duration = Duration::from_secs(15);
pub(crate) fn is_connected(reader: Reader) -> bool {
filter_connected(&reader)
}
pub(crate) fn filter_connected(reader: &Reader) -> bool {
match reader.open() {
Ok(_) => true,
@@ -55,7 +59,7 @@ pub(crate) fn wait_for_readers() -> Result<Readers, Error> {
let start = SystemTime::now();
loop {
let mut readers = Readers::open()?;
if readers.iter()?.filter(filter_connected).next().is_some() {
if readers.iter()?.any(is_connected) {
break Ok(readers);
}
@@ -67,12 +71,7 @@ pub(crate) fn wait_for_readers() -> Result<Readers, Error> {
}
pub(crate) fn open(serial: Option<Serial>) -> Result<YubiKey, Error> {
if Readers::open()?
.iter()?
.filter(filter_connected)
.next()
.is_none()
{
if !Readers::open()?.iter()?.any(is_connected) {
if let Some(serial) = serial {
eprintln!("⏳ Please insert the YubiKey with serial {}.", serial);
} else {