From 93e792088c6b2d3ed0cf6a11aec9fa1aa6ef55a1 Mon Sep 17 00:00:00 2001 From: Anas Elgarhy Date: Wed, 12 Oct 2022 18:56:26 +0200 Subject: [PATCH] =?UTF-8?q?Improve=20the=20code=20yooo=20=F0=9F=A5=B0?= =?UTF-8?q?=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bf_interpreter/interpreter.rs | 2 +- src/main.rs | 2 +- src/repl.rs | 14 ++++---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/bf_interpreter/interpreter.rs b/src/bf_interpreter/interpreter.rs index 12c2b7e..a72d921 100644 --- a/src/bf_interpreter/interpreter.rs +++ b/src/bf_interpreter/interpreter.rs @@ -1,6 +1,6 @@ use crate::arguments; use crate::bf_interpreter::error::{InterpreterError, InterpreterErrorKind}; -use std::io::{BufRead, Read, Write}; +use std::io::{Read, Write}; use std::{char, usize, vec}; pub struct Interpreter { diff --git a/src/main.rs b/src/main.rs index 15f4954..ab4fd0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ mod repl; mod utils; mod bf_interpreter; -use std::io::{BufRead, Write}; + use clap::Parser; extern crate pretty_env_logger; #[macro_use] diff --git a/src/repl.rs b/src/repl.rs index b14339e..d9f04d3 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -1,10 +1,10 @@ use crate::bf_interpreter::interpreter::Interpreter; -use std::io::{Write, Read, BufRead, BufReader, Stdout, Stdin}; +use std::io::{Write, BufRead}; use colored::Colorize; -use no_panic::no_panic; + struct Repl { - interpreter: Interpreter, + pub interpreter: Interpreter, history: Vec, loop_body: String, loop_depth: usize, @@ -211,12 +211,6 @@ impl Repl { None => {} } } - - /// Get the interpreter - /// for testing purposes only! - pub fn interpreter(&self) -> &Interpreter { - &self.interpreter - } } /// Run the REPL @@ -267,7 +261,7 @@ mod tests { repl.process("[>+<-]".to_string()); repl.process("<-]".to_string()); - let cells = &repl.interpreter().cells; + let cells = &repl.interpreter.cells; assert_eq!(cells[0], 0); assert_eq!(cells[1], 0);