Skip to content

Commit

Permalink
replace map with fold
Browse files Browse the repository at this point in the history
  • Loading branch information
hitchhooker committed Apr 16, 2024
1 parent 1793738 commit ad3fb59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polka-run"
version = "0.4.0"
version = "0.5.0"
edition = "2021"

[lib]
Expand Down
7 changes: 5 additions & 2 deletions app/src/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,11 @@ pub fn Disassembler() -> impl IntoView {
let size = instruction.serialize_into(&mut serialized);
let hex_buffer = serialized[..size]
.iter()
.map(|byte| format!("{:02X} ", byte))
.collect::<String>();
.fold(String::new(), |mut acc, byte| {
use std::fmt::Write;
write!(acc, "{:02X} ", byte).expect("Failed to write to String");
acc
});

// Extract the opcode name from the instruction
let opcode_name = format!("{:?}", instruction.opcode());
Expand Down

0 comments on commit ad3fb59

Please sign in to comment.