style: don't bury fn main
This commit is contained in:
parent
c8bc766e2a
commit
6e14c4e967
1 changed files with 15 additions and 15 deletions
30
src/main.rs
30
src/main.rs
|
|
@ -8,6 +8,21 @@ use rug::Float;
|
||||||
|
|
||||||
mod nodes;
|
mod nodes;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = match env::args().skip(1).reduce(|x, a| a + &x) {
|
||||||
|
Some(s) => s,
|
||||||
|
None => {
|
||||||
|
let mut buf = String::new();
|
||||||
|
io::stdin().read_to_string(&mut buf).unwrap();
|
||||||
|
buf
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = parse_and_calc(&input);
|
||||||
|
|
||||||
|
println!("{result:.0$}", get_significant_digits(&result));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_and_calc(s: &str) -> Float {
|
pub fn parse_and_calc(s: &str) -> Float {
|
||||||
nodes::Nodes::from_str(s).unwrap().evaluate()
|
nodes::Nodes::from_str(s).unwrap().evaluate()
|
||||||
}
|
}
|
||||||
|
|
@ -47,18 +62,3 @@ pub fn get_significant_digits(n: &Float) -> usize {
|
||||||
|
|
||||||
significant_digits
|
significant_digits
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let input = match env::args().skip(1).reduce(|x, a| a + &x) {
|
|
||||||
Some(s) => s,
|
|
||||||
None => {
|
|
||||||
let mut buf = String::new();
|
|
||||||
io::stdin().read_to_string(&mut buf).unwrap();
|
|
||||||
buf
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = parse_and_calc(&input);
|
|
||||||
|
|
||||||
println!("{result:.0$}", get_significant_digits(&result));
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue