Cargo fmt
This commit is contained in:
parent
4d1badc36b
commit
0d67e393c1
30
src/calc.rs
30
src/calc.rs
@ -264,26 +264,44 @@ impl Calculator {
|
|||||||
'_' => self.display_mode = CalculatorDisplayMode::Default,
|
'_' => self.display_mode = CalculatorDisplayMode::Default,
|
||||||
',' => self.display_mode = CalculatorDisplayMode::Separated { separator: ',' },
|
',' => self.display_mode = CalculatorDisplayMode::Separated { separator: ',' },
|
||||||
' ' => self.display_mode = CalculatorDisplayMode::Separated { separator: ' ' },
|
' ' => self.display_mode = CalculatorDisplayMode::Separated { separator: ' ' },
|
||||||
's' => self.display_mode = CalculatorDisplayMode::Scientific{precision: DEFAULT_PRECISION},
|
's' => {
|
||||||
|
self.display_mode = CalculatorDisplayMode::Scientific {
|
||||||
|
precision: DEFAULT_PRECISION,
|
||||||
|
}
|
||||||
|
}
|
||||||
'S' => {
|
'S' => {
|
||||||
let precision = self.checked_get(0)? as usize;
|
let precision = self.checked_get(0)? as usize;
|
||||||
if precision > MAX_PRECISION {
|
if precision > MAX_PRECISION {
|
||||||
return Err(CalculatorError::PrecisionTooHigh);
|
return Err(CalculatorError::PrecisionTooHigh);
|
||||||
}
|
}
|
||||||
self.display_mode = CalculatorDisplayMode::Scientific{precision: self.pop_usize()?}
|
self.display_mode = CalculatorDisplayMode::Scientific {
|
||||||
|
precision: self.pop_usize()?,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
'e' => {
|
'e' => {
|
||||||
self.display_mode = CalculatorDisplayMode::Engineering{precision: DEFAULT_PRECISION}
|
self.display_mode = CalculatorDisplayMode::Engineering {
|
||||||
|
precision: DEFAULT_PRECISION,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
'E' => {
|
'E' => {
|
||||||
let precision = self.checked_get(0)? as usize;
|
let precision = self.checked_get(0)? as usize;
|
||||||
if precision > MAX_PRECISION {
|
if precision > MAX_PRECISION {
|
||||||
return Err(CalculatorError::PrecisionTooHigh);
|
return Err(CalculatorError::PrecisionTooHigh);
|
||||||
}
|
}
|
||||||
self.display_mode = CalculatorDisplayMode::Engineering{precision: self.pop_usize()?}
|
self.display_mode = CalculatorDisplayMode::Engineering {
|
||||||
|
precision: self.pop_usize()?,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'f' => {
|
||||||
|
self.display_mode = CalculatorDisplayMode::Fixed {
|
||||||
|
precision: DEFAULT_PRECISION,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'F' => {
|
||||||
|
self.display_mode = CalculatorDisplayMode::Fixed {
|
||||||
|
precision: self.pop_usize()?,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
'f' => self.display_mode = CalculatorDisplayMode::Fixed{precision: DEFAULT_PRECISION},
|
|
||||||
'F' => self.display_mode = CalculatorDisplayMode::Fixed{precision: self.pop_usize()?},
|
|
||||||
_ => return Err(CalculatorError::NoSuchSetting(c)),
|
_ => return Err(CalculatorError::NoSuchSetting(c)),
|
||||||
};
|
};
|
||||||
self.state = CalculatorState::Normal;
|
self.state = CalculatorState::Normal;
|
||||||
|
@ -39,10 +39,14 @@ impl fmt::Display for CalculatorError {
|
|||||||
CalculatorError::ParseError => write!(f, "Parse error"),
|
CalculatorError::ParseError => write!(f, "Parse error"),
|
||||||
CalculatorError::PrecisionTooHigh => write!(f, "Precision too high"),
|
CalculatorError::PrecisionTooHigh => write!(f, "Precision too high"),
|
||||||
CalculatorError::SaveError(None) => write!(f, "Could not save"),
|
CalculatorError::SaveError(None) => write!(f, "Could not save"),
|
||||||
CalculatorError::SaveError(Some(ConfyError::SerializeTomlError(e))) => write!(f, "Save serialization error: {}", e),
|
CalculatorError::SaveError(Some(ConfyError::SerializeTomlError(e))) => {
|
||||||
|
write!(f, "Save serialization error: {}", e)
|
||||||
|
}
|
||||||
CalculatorError::SaveError(Some(e)) => write!(f, "Could not save: {}", e),
|
CalculatorError::SaveError(Some(e)) => write!(f, "Could not save: {}", e),
|
||||||
CalculatorError::LoadError(None) => write!(f, "Could not load"),
|
CalculatorError::LoadError(None) => write!(f, "Could not load"),
|
||||||
CalculatorError::LoadError(Some(ConfyError::SerializeTomlError(e))) => write!(f, "Load serialization error: {}", e),
|
CalculatorError::LoadError(Some(ConfyError::SerializeTomlError(e))) => {
|
||||||
|
write!(f, "Load serialization error: {}", e)
|
||||||
|
}
|
||||||
CalculatorError::LoadError(Some(e)) => write!(f, "Could not load: {}", e),
|
CalculatorError::LoadError(Some(e)) => write!(f, "Could not load: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user