From ad3fb5902dcf0481e532845f8e52075173ef8e3b Mon Sep 17 00:00:00 2001 From: hitchhooker Date: Tue, 16 Apr 2024 12:31:55 +0700 Subject: [PATCH] replace map with fold --- app/Cargo.toml | 2 +- app/src/disassembler.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Cargo.toml b/app/Cargo.toml index 2338b09..7aff1ad 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polka-run" -version = "0.4.0" +version = "0.5.0" edition = "2021" [lib] diff --git a/app/src/disassembler.rs b/app/src/disassembler.rs index 1c21151..95be04c 100644 --- a/app/src/disassembler.rs +++ b/app/src/disassembler.rs @@ -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::(); + .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());