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;
|
use tylc as lib;
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let input = match env::args().skip(1).rev().reduce(|x, a| a + &x) {
|
let input = env::args()
|
||||||
Some(s) => s,
|
.skip(1)
|
||||||
None => {
|
.rev()
|
||||||
|
.reduce(|x, a| a + &x)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
io::stdin().read_to_string(&mut buf).unwrap();
|
io::stdin().read_to_string(&mut buf).unwrap();
|
||||||
buf
|
buf
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
match lib::formatting::pretty_eval(input, 10) {
|
match lib::formatting::pretty_eval(input, 10) {
|
||||||
Ok(s) => println!("{s}"),
|
Ok(s) => println!("{s}"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue