mirror of
https://github.com/ivabus/feval
synced 2024-12-05 05:05:07 +03:00
Add error handling
This commit is contained in:
parent
27a825b2a2
commit
ebfe95e632
1 changed files with 5 additions and 1 deletions
|
@ -14,7 +14,11 @@ fn main_loop() {
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
while stdin().read_line(&mut input).unwrap() != 0 {
|
while stdin().read_line(&mut input).unwrap() != 0 {
|
||||||
println!("{}", evalexpr::eval(&input.trim()).unwrap());
|
let result = evalexpr::eval(&input.trim());
|
||||||
|
match result {
|
||||||
|
Ok(succ_res) => println!("{}", succ_res),
|
||||||
|
Err(_) => println!("Invalid input")
|
||||||
|
}
|
||||||
input.clear();
|
input.clear();
|
||||||
print!(">>> ");
|
print!(">>> ");
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue