cargo: fmt
This commit is contained in:
parent
a40eba6f8d
commit
ec3f371313
1 changed files with 51 additions and 48 deletions
13
src/main.rs
13
src/main.rs
|
@ -2,10 +2,7 @@ use std::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, BufRead, BufReader};
|
use std::io::{self, BufRead, BufReader};
|
||||||
|
|
||||||
fn retrieve(
|
fn retrieve(memory: &mut HashMap<String, i64>, ops: Vec<String>) -> i64 {
|
||||||
memory: &mut HashMap<String, i64>,
|
|
||||||
ops: Vec<String>
|
|
||||||
) -> i64 {
|
|
||||||
if ops.len() >= 3 {
|
if ops.len() >= 3 {
|
||||||
return *memory.get(&ops[2]).unwrap_or(&0);
|
return *memory.get(&ops[2]).unwrap_or(&0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,7 +105,13 @@ fn main() -> io::Result<()> {
|
||||||
let mut pc: usize = 0;
|
let mut pc: usize = 0;
|
||||||
while pc < code.len() {
|
while pc < code.len() {
|
||||||
let line = &code[pc];
|
let line = &code[pc];
|
||||||
let next_pc = process(line.to_string(), &mut accumulator, &mut memory, &labels, &mut pc);
|
let next_pc = process(
|
||||||
|
line.to_string(),
|
||||||
|
&mut accumulator,
|
||||||
|
&mut memory,
|
||||||
|
&labels,
|
||||||
|
&mut pc,
|
||||||
|
);
|
||||||
if next_pc != 0 {
|
if next_pc != 0 {
|
||||||
pc = next_pc;
|
pc = next_pc;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue