diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index d588823..358ac4e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ use std::env; use std::fs; use std::io; use std::io::prelude::*; -use std::string::String; use std::sync::{Arc, Condvar, Mutex}; use std::thread::sleep; use std::{thread, time}; @@ -13,13 +12,13 @@ use self::core::Core; fn core_worker(mut core: Core, should_stop: &Mutex<bool>, cvar: &Condvar) { loop { - while false == *should_stop.lock().unwrap() { + while !(*should_stop.lock().unwrap()) { core.step(); println!("{}", core.op()); sleep(time::Duration::from_millis(1000)); } - while true == *should_stop.lock().unwrap() { + while *should_stop.lock().unwrap() { let _ = cvar.wait(should_stop.lock().unwrap()).unwrap(); } } @@ -51,12 +50,12 @@ fn main() { println!("Please, specify ihex file"); return; } - let data = fs::read_to_string(&args[1]).expect(&format!("Unable to read file {}", &args[1])); + let data = fs::read_to_string(&args[1]).unwrap_or_else(|_| panic!("Unable to read file {}", &args[1])); let asyncpair = Arc::new((Mutex::new(false), Condvar::new())); let asyncpair2 = asyncpair.clone(); - let core = match Core::new_with_ram_from_hex(String::from(data)) { + let core = match Core::new_with_ram_from_hex(data) { Ok(value) => value, Err(err_string) => { println!("{}", err_string); |