refactor: simplify input logic
This commit is contained in:
parent
d6b9d7a407
commit
e59f928192
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -7,14 +7,15 @@ use std::{
|
|||
use tylc as lib;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let input = match env::args().skip(1).rev().reduce(|x, a| a + &x) {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
let input = env::args()
|
||||
.skip(1)
|
||||
.rev()
|
||||
.reduce(|x, a| a + &x)
|
||||
.unwrap_or_else(|| {
|
||||
let mut buf = String::new();
|
||||
io::stdin().read_to_string(&mut buf).unwrap();
|
||||
buf
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
match lib::formatting::pretty_eval(input, 10) {
|
||||
Ok(s) => println!("{s}"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue