Added a fmt file and formatted the whole project

master
Wynd 2024-10-22 16:14:15 +03:00
parent 659f9fbe65
commit f39dde9c64
6 changed files with 233 additions and 222 deletions

8
rustfmt.toml 100644
View File

@ -0,0 +1,8 @@
unstable_features = true
reorder_imports = true
hard_tabs = true
control_brace_style = "ClosingNextLine"
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
edition = "2021"
newline_style = "Unix"

View File

@ -16,7 +16,8 @@ pub fn run(program: Vec<u8>) {
for (ip, instruction) in program.iter().enumerate() { for (ip, instruction) in program.iter().enumerate() {
if *instruction == b'[' { if *instruction == b'[' {
stack.push_back(ip); stack.push_back(ip);
} else if *instruction == b']' { }
else if *instruction == b']' {
let begin_index = stack.pop_back().unwrap(); let begin_index = stack.pop_back().unwrap();
table.insert(begin_index, ip); table.insert(begin_index, ip);
table.insert(ip, begin_index); table.insert(ip, begin_index);
@ -24,7 +25,8 @@ pub fn run(program: Vec<u8>) {
} }
while ip < program.len() { while ip < program.len() {
let Some(instruction) = program.get(ip) else { let Some(instruction) = program.get(ip)
else {
break; break;
}; };

View File

@ -26,7 +26,8 @@ pub fn tokenize(program: Vec<u8>) -> Vec<Token> {
let mut ip = 0; let mut ip = 0;
while ip < program.len() { while ip < program.len() {
let Some(instruction) = program.get(ip) else { let Some(instruction) = program.get(ip)
else {
break; break;
}; };