This commit is contained in:
Austen Adler 2021-10-02 08:45:37 -04:00
parent dc30a93d61
commit 6bf83540fb
8 changed files with 40 additions and 33 deletions

View File

@ -11,10 +11,8 @@ use errors::{CalculatorError, CalculatorResult};
use operations::{
ArithmeticOperation, CalculatorOperation, CalculatorStateChange, MacroState, OpArgs,
};
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap};
use std::collections::{HashSet, VecDeque};
use serde::{ser::Serializer, Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
use types::{
CalculatorAlignment, CalculatorAngleMode, CalculatorConstant, CalculatorConstants,
CalculatorDisplayMode, CalculatorMacro, CalculatorMacros, CalculatorRegisters, CalculatorState,
@ -307,7 +305,9 @@ impl Calculator {
self.state = CalculatorState::WaitingForSetting;
Ok(())
}
c => self.op(OPERATION_MAP.get(&c).ok_or(CalculatorError::NoSuchOperator(c))?),
c => self.op(OPERATION_MAP
.get(&c)
.ok_or(CalculatorError::NoSuchOperator(c))?),
}
}
fn constant_input(&mut self, c: char) -> CalculatorResult<()> {

View File

@ -4,13 +4,11 @@ mod matrix;
mod number;
mod vector;
use super::errors::{CalculatorError, CalculatorResult};
use crate::calc::types::CalculatorAngleMode;
use crate::calc::CalculatorDisplayMode;
use crate::calc::{types::CalculatorAngleMode, CalculatorDisplayMode};
pub use matrix::{Matrix, MatrixDimensions};
pub use number::Number;
use serde::{Deserialize, Serialize};
use std::cmp::PartialEq;
use std::fmt;
use std::{cmp::PartialEq, fmt};
pub use vector::{Vector, VectorDirection};
pub trait CalculatorEntry

View File

@ -1,9 +1,12 @@
use super::VectorDirection;
use super::{Entry, Number, Vector};
use crate::calc::errors::{CalculatorError, CalculatorResult};
use crate::calc::types::CalculatorAngleMode;
use crate::calc::CalculatorDisplayMode;
use crate::CalculatorEntry;
use super::{Entry, Number, Vector, VectorDirection};
use crate::{
calc::{
errors::{CalculatorError, CalculatorResult},
types::CalculatorAngleMode,
CalculatorDisplayMode,
},
CalculatorEntry,
};
use serde::{Deserialize, Serialize};
use std::fmt;

View File

@ -1,9 +1,12 @@
use super::VectorDirection;
use super::{Entry, Matrix, Vector};
use crate::calc::errors::{CalculatorError, CalculatorResult};
use crate::calc::types::CalculatorAngleMode;
use crate::calc::CalculatorDisplayMode;
use crate::CalculatorEntry;
use super::{Entry, Matrix, Vector, VectorDirection};
use crate::{
calc::{
errors::{CalculatorError, CalculatorResult},
types::CalculatorAngleMode,
CalculatorDisplayMode,
},
CalculatorEntry,
};
use serde::{Deserialize, Serialize};
use std::fmt;

View File

@ -1,8 +1,12 @@
use super::{Entry, Matrix, Number};
use crate::calc::errors::{CalculatorError, CalculatorResult};
use crate::calc::types::CalculatorAngleMode;
use crate::calc::CalculatorDisplayMode;
use crate::CalculatorEntry;
use crate::{
calc::{
errors::{CalculatorError, CalculatorResult},
types::CalculatorAngleMode,
CalculatorDisplayMode,
},
CalculatorEntry,
};
use serde::{Deserialize, Serialize};
use std::fmt;

View File

@ -1,6 +1,5 @@
use confy::ConfyError;
use std::error;
use std::fmt;
use std::{error, fmt};
pub type CalculatorResult<T> = Result<T, CalculatorError>;

View File

@ -1,7 +1,6 @@
use super::entries::Entry;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::{collections::HashMap, fmt};
/// The calculator state
#[derive(Debug, Serialize, Deserialize)]

View File

@ -1,8 +1,9 @@
use std::iter;
use std::sync::mpsc;
use std::{iter, sync::mpsc};
use std::thread;
use std::time::{Duration, Instant};
use std::{
thread,
time::{Duration, Instant},
};
use crossterm::event::{self, Event as CEvent, KeyEvent};