diff --git a/src/format.rs b/src/format.rs index 89c8d36..5658f37 100644 --- a/src/format.rs +++ b/src/format.rs @@ -77,7 +77,7 @@ pub fn separated(f: f64, sep: char) -> String { mod tests { use super::*; #[test] - fn test_fmt_scientific() { + fn test_scientific() { for (f, p, s) in vec![ // Basic (1.0, 0, " 1 E+00"), @@ -102,12 +102,12 @@ mod tests { (1.5, 1, " 1.5 E+00"), (1.5, 0, " 2 E+00"), ] { - assert_eq!(fmt_scientific(f, p), s); + assert_eq!(scientific(f, p), s); } } #[test] - fn test_fmt_separated() { + fn test_separated() { for (f, c, s) in vec![ (100.0, ',', "100"), (100.0, ',', "100"), @@ -125,12 +125,12 @@ mod tests { (1_000_000.123456789, ' ', "1 000 000.123456789"), (1_000_000.123456789, ' ', "1 000 000.123456789"), ] { - assert_eq!(fmt_separated(f, c), s); + assert_eq!(separated(f, c), s); } } #[test] - fn test_fmt_engineering() { + fn test_engineering() { for (f, c, s) in vec![ (100.0, 3, " 100.000 E+00"), (100.0, 3, " 100.000 E+00"), @@ -149,7 +149,7 @@ mod tests { (1.5, 1, " 1.5 E+00"), (1.5, 0, " 2. E+00"), ] { - assert_eq!(fmt_engineering(f, c), s); + assert_eq!(engineering(f, c), s); } } } diff --git a/src/main.rs b/src/main.rs index 8c83488..bd46a3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use calc::constants::{CalculatorDisplayMode, CalculatorState, RegisterState}; use calc::errors::CalculatorResult; use calc::Calculator; use crossterm::{ - event::{self, DisableMouseCapture, Event as CEvent, KeyCode, KeyEvent, KeyModifiers}, + event::{DisableMouseCapture, KeyCode, KeyEvent, KeyModifiers}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; @@ -18,8 +18,7 @@ use io::stdout; use std::cmp; use std::convert::TryFrom; use std::io::Write; -use std::sync::mpsc; -use std::thread; + use std::{error::Error, io}; use tui::{ backend::CrosstermBackend, @@ -370,7 +369,7 @@ fn handle_key(app: &mut App, key: KeyEvent) -> CalculatorResult { - for c in (c.to_uppercase()) { + for c in c.to_uppercase() { app.calculator.take_input(c)?; } } diff --git a/src/util/event.rs b/src/util/event.rs index 7fa70a4..e0a8b4e 100644 --- a/src/util/event.rs +++ b/src/util/event.rs @@ -1,15 +1,11 @@ -use std::io; use std::iter; use std::sync::mpsc; -use std::sync::mpsc::{Iter, TryIter}; -use std::sync::{ - atomic::{AtomicBool, Ordering}, - Arc, -}; +use std::sync::mpsc::TryIter; + use std::thread; use std::time::{Duration, Instant}; -use crossterm::event::{self, Event as CEvent, KeyCode, KeyEvent, KeyModifiers}; +use crossterm::event::{self, Event as CEvent, KeyEvent}; pub enum Event { Input(I), @@ -57,7 +53,12 @@ impl Events { /// Returns a chain of the next element (blocking) and a TryIter of everything after it. /// Useful for reading a single Iterator of all elements once after blocking, so there are not too many UI redraws. - pub fn blocking_iter(&self) -> Result>,TryIter>>, mpsc::RecvError> { - Ok(iter::once(self.rx.recv()?).chain(self.rx.try_iter()).into_iter()) + pub fn blocking_iter( + &self, + ) -> Result>, TryIter>>, mpsc::RecvError> + { + Ok(iter::once(self.rx.recv()?) + .chain(self.rx.try_iter()) + .into_iter()) } }