From b0a29f90414ac85ff0fe9959cb42e587426784ed Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:22:42 +0300 Subject: [PATCH 1/6] Update main.rs --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index 812ec7c..48e1310 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(box_syntax)] + use clap::Parser; use std::fs; use std::time::Instant; From 4ce6784b08ec8a1238ed37b7a3ac695d289ad8a4 Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:26:45 +0300 Subject: [PATCH 2/6] Custom panic --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.rs b/src/main.rs index 48e1310..644a609 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,15 @@ mod interpreter; use interpreter::Interpreter; fn main() { + std::panic::set_hook( + box |info| { + eprint!("{msg}", msg = match info.message() { + None => "Program panicked!".to_owned(), + Some(x) => x.to_string() + }); + } + ); + let start = Instant::now(); let args = Args::parse(); From 5a0189b6ae92d76c460277c2da6147d22ff1619a Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:30:49 +0300 Subject: [PATCH 3/6] Update interpreter.rs --- src/interpreter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index 7e6ac50..dd16ea7 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -219,8 +219,8 @@ impl Interpreter { fn input(&self, value: &String) -> Value { let mut input = String::new(); print!("{}", value); - io::stdout().flush().unwrap_or_default(); - io::stdin().read_line(&mut input).unwrap_or_default(); + io::stdout().flush().expect("Couldn't flush Stdout"); + io::stdin().read_line(&mut input).expect("Couldn't read from Stdin"); Value::String(input.trim_end().to_string()) } From cad4ec224b26b2260e1d2d51149bb3272272fc4b Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:47:13 +0300 Subject: [PATCH 4/6] Nightly to Stable --- src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 644a609..6928b53 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -#![feature(box_syntax)] - use clap::Parser; use std::fs; use std::time::Instant; @@ -18,12 +16,12 @@ use interpreter::Interpreter; fn main() { std::panic::set_hook( - box |info| { + Box::new(|info| { eprint!("{msg}", msg = match info.message() { None => "Program panicked!".to_owned(), Some(x) => x.to_string() }); - } + }) ); let start = Instant::now(); From d2ecdfc997ae7a9923d2e05d11c70b5da2830476 Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:48:10 +0300 Subject: [PATCH 5/6] Update interpreter.rs --- src/interpreter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index dd16ea7..1c89cf4 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -14,8 +14,8 @@ pub struct Interpreter { } impl Interpreter { - pub fn new(input: String) -> Interpreter { - Interpreter { + pub fn new(input: String) -> Self { + Self { input, vars: HashMap::new(), pos: 1, From ab43d8f201f661d35f1f2bb6d0c0444981d7f5a1 Mon Sep 17 00:00:00 2001 From: mrMiiao <90341146+mrMiiao@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:57:41 +0300 Subject: [PATCH 6/6] Stable -> Nightly --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6928b53..fc2e8f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(box_syntax, panic_info_message)] + use clap::Parser; use std::fs; use std::time::Instant; @@ -16,12 +18,12 @@ use interpreter::Interpreter; fn main() { std::panic::set_hook( - Box::new(|info| { + box |info| { eprint!("{msg}", msg = match info.message() { None => "Program panicked!".to_owned(), Some(x) => x.to_string() }); - }) + } ); let start = Instant::now();