From 01a1e5e4f45dc80cd430d18492817b733fab5603 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 26 Feb 2022 22:23:34 +0100 Subject: Fix linter warnings --- src/util/event.rs | 10 ++++------ src/util/serialization.rs | 6 +++--- src/util/time.rs | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/util') diff --git a/src/util/event.rs b/src/util/event.rs index 33ee9ec..05d8581 100644 --- a/src/util/event.rs +++ b/src/util/event.rs @@ -43,12 +43,10 @@ impl Events { let tx = tx.clone(); thread::spawn(move || { let stdin = io::stdin(); - for evt in stdin.keys() { - if let Ok(key) = evt { - if let Err(err) = tx.send(Event::Input(key)) { - eprintln!("{}", err); - return; - } + for key in stdin.keys().flatten() { + if let Err(err) = tx.send(Event::Input(key)) { + eprintln!("{}", err); + return; } } }) diff --git a/src/util/serialization.rs b/src/util/serialization.rs index cc2899f..61b3a83 100644 --- a/src/util/serialization.rs +++ b/src/util/serialization.rs @@ -1,10 +1,10 @@ -pub fn line_to_words(line: &String) -> Vec { - line.split("|") +pub fn line_to_words(line: &str) -> Vec { + line.split('|') .map(|w| w.trim().to_string()) .filter(|w| !w.is_empty()) .collect() } -pub fn words_to_line(words: &Vec) -> String { +pub fn words_to_line(words: &[String]) -> String { words.join(" | ") } diff --git a/src/util/time.rs b/src/util/time.rs index d9a9f72..b8a85e6 100644 --- a/src/util/time.rs +++ b/src/util/time.rs @@ -3,7 +3,7 @@ use std::thread; use std::time::SystemTime; pub fn seconds_since_unix_epoch() -> Result { - Ok(seconds_since_unix_epoch_of(SystemTime::now())?) + seconds_since_unix_epoch_of(SystemTime::now()) } pub fn seconds_since_unix_epoch_of(time: SystemTime) -> Result { -- cgit v1.2.3