From 3facaa10a24755f6e868a10952991ee9d3c6a6a3 Mon Sep 17 00:00:00 2001 From: b1ek Date: Tue, 22 Aug 2023 22:46:18 +1000 Subject: [PATCH] don't throw runtime error when stdin closes --- examples/hello_world.rs | 6 +----- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/hello_world.rs b/examples/hello_world.rs index b31f50f..6871223 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -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()); } } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 527d9fa..4ebd562 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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() {