don't throw runtime error when stdin closes

This commit is contained in:
b1ek 2023-08-22 22:46:18 +10:00
parent dce22d5719
commit 3facaa10a2
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 2 additions and 6 deletions

View File

@ -7,10 +7,6 @@ fn main() {
)
);
if eval.is_err() {
let err = eval.unwrap_err();
if err == "Stdin closed" {
return
}
eprintln!("Program failed: {}", err);
eprintln!("Program failed: \n{}", eval.unwrap_err());
}
}

View File

@ -119,7 +119,7 @@ pub fn eval_mem(bf_str: &&str, mem: &mut [u8], pointer: &mut usize) -> Result<()
if char == ',' {
let byte = stdin().bytes().next();
if byte.is_none() {
return Err("Stdin closed".into());
continue
}
let byte = byte.unwrap();
if byte.is_err() {