diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/event.rs | 10 | ||||
-rw-r--r-- | src/util/serialization.rs | 6 | ||||
-rw-r--r-- | src/util/time.rs | 2 |
3 files changed, 8 insertions, 10 deletions
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<String> { - line.split("|") +pub fn line_to_words(line: &str) -> Vec<String> { + line.split('|') .map(|w| w.trim().to_string()) .filter(|w| !w.is_empty()) .collect() } -pub fn words_to_line(words: &Vec<String>) -> 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<u64> { - 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<u64> { |