Clippy
This commit is contained in:
parent
620db0e5d1
commit
87d554f8e8
14
src/main.rs
14
src/main.rs
|
@ -11,7 +11,7 @@ fn main() {
|
||||||
let program = std::fs::read_to_string(args.get(1).unwrap()).unwrap();
|
let program = std::fs::read_to_string(args.get(1).unwrap()).unwrap();
|
||||||
|
|
||||||
let mut machine = Machine::new(program);
|
let mut machine = Machine::new(program);
|
||||||
if let Some(_) = args.get(2) {
|
if args.get(2).is_some() {
|
||||||
loop {
|
loop {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
std::io::stdin().read_line(&mut input).unwrap();
|
std::io::stdin().read_line(&mut input).unwrap();
|
||||||
|
@ -63,6 +63,8 @@ struct Machine {
|
||||||
data: Vec<Cell>,
|
data: Vec<Cell>,
|
||||||
instructions: Vec<Instruction>,
|
instructions: Vec<Instruction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq)]
|
||||||
struct Cell {
|
struct Cell {
|
||||||
value: u8,
|
value: u8,
|
||||||
|
@ -170,7 +172,7 @@ impl Machine {
|
||||||
.get(self.data_pointer)
|
.get(self.data_pointer)
|
||||||
.unwrap_or(&Cell { value: 0 })
|
.unwrap_or(&Cell { value: 0 })
|
||||||
.value;
|
.value;
|
||||||
let c: char = (value as u8).into();
|
let c: char = value.into();
|
||||||
print!("{c}");
|
print!("{c}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +180,7 @@ impl Machine {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
std::io::stdin().read_line(&mut input).unwrap();
|
std::io::stdin().read_line(&mut input).unwrap();
|
||||||
|
|
||||||
let value = *input.into_bytes().first().unwrap() as u8;
|
let value = *input.into_bytes().first().unwrap();
|
||||||
|
|
||||||
let cell = Cell { value };
|
let cell = Cell { value };
|
||||||
|
|
||||||
|
@ -229,7 +231,7 @@ impl Machine {
|
||||||
|
|
||||||
let repetitions: usize = input.trim().parse().unwrap();
|
let repetitions: usize = input.trim().parse().unwrap();
|
||||||
|
|
||||||
let mut bar = indicatif::ProgressBar::new(repetitions as u64);
|
let bar = indicatif::ProgressBar::new(repetitions as u64);
|
||||||
bar.set_style(
|
bar.set_style(
|
||||||
ProgressStyle::with_template(
|
ProgressStyle::with_template(
|
||||||
"{bar:40} | {human_pos}/{human_len} | {eta_precise} | {elapsed_precise}",
|
"{bar:40} | {human_pos}/{human_len} | {eta_precise} | {elapsed_precise}",
|
||||||
|
@ -363,9 +365,7 @@ fn locate_jmp_target_jiz(
|
||||||
let mut data_pointer = index + 1;
|
let mut data_pointer = index + 1;
|
||||||
let mut searched_jinz = 1;
|
let mut searched_jinz = 1;
|
||||||
let mut instruction_index = instruction_index;
|
let mut instruction_index = instruction_index;
|
||||||
if instruction_index != 0 {
|
instruction_index = instruction_index.saturating_sub(1);
|
||||||
instruction_index -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while searched_jinz != 0 {
|
while searched_jinz != 0 {
|
||||||
if data_pointer == program_vector.len() {
|
if data_pointer == program_vector.len() {
|
||||||
|
|
Loading…
Reference in a new issue