Separate calculator display code
This commit is contained in:
parent
af00ba5e28
commit
5d5a3e4a21
33
src/main.rs
33
src/main.rs
@ -225,23 +225,22 @@ impl App {
|
||||
.enumerate()
|
||||
.rev()
|
||||
.map(|(i, m)| {
|
||||
let content = vec![Spans::from(Span::raw(
|
||||
match self.calculator.get_display_mode() {
|
||||
CalculatorDisplayMode::Default => format!("{:>2}: {}", i, *m),
|
||||
CalculatorDisplayMode::Separated { separator } => {
|
||||
format!("{:>2}: {}", i, format::separated(*m, *separator))
|
||||
}
|
||||
CalculatorDisplayMode::Scientific { precision } => {
|
||||
format!("{:>2}: {}", i, format::scientific(*m, *precision))
|
||||
}
|
||||
CalculatorDisplayMode::Engineering { precision } => {
|
||||
format!("{:>2}: {}", i, format::engineering(*m, *precision))
|
||||
}
|
||||
CalculatorDisplayMode::Fixed { precision } => {
|
||||
format!("{:>2}: {:.precision$}", i, m, precision = precision)
|
||||
}
|
||||
},
|
||||
))];
|
||||
let number = match self.calculator.get_display_mode() {
|
||||
CalculatorDisplayMode::Default => format!("{}", m),
|
||||
CalculatorDisplayMode::Separated { separator } => {
|
||||
format::separated(*m, *separator)
|
||||
}
|
||||
CalculatorDisplayMode::Scientific { precision } => {
|
||||
format::scientific(*m, *precision)
|
||||
}
|
||||
CalculatorDisplayMode::Engineering { precision } => {
|
||||
format::engineering(*m, *precision)
|
||||
}
|
||||
CalculatorDisplayMode::Fixed { precision } => {
|
||||
format!("{:0>.precision$}", m, precision = precision)
|
||||
}
|
||||
};
|
||||
let content = vec![Spans::from(Span::raw(format!("{:>2}: {}", i, number)))];
|
||||
ListItem::new(content)
|
||||
})
|
||||
.collect();
|
||||
|
Loading…
Reference in New Issue
Block a user