Repository: nexus-xyz/nexus-zkvm
File: vm/src/emulator/executor.rs (Rust)

Code before:
                    .enumerate()
                    .map(move |(j, byte)| MemoryInitializationEntry {
                        address: base_address + j as u32,
                        value: byte,
                    })
            });

        let public_io_loc_iter = self
            .memory
            .segment_words(self.public_io_location_index, 0x80, None)
            .expect("Cannot find public io location in LinearEmulator")
            .iter()
            .enumerate()
            .flat_map(|(i, word_content)| {
                let base_address = 0x80 + i as u32 * WORD_SIZE as u32;
                let word = word_content.to_le_bytes();
                word.into_iter()
                    .enumerate()
                    .map(move |(j, byte)| MemoryInitializationEntry {
                        address: base_address + j as u32,
                        value: byte,
                    })
            });

        // Helper function to map (addr, byte) to MemoryInitializationEntry
        fn map_to_mem_init_entry((addr, byte): (u32, u8)) -> MemoryInitializationEntry {
            MemoryInitializationEntry {
                address: addr,
                value: byte,
            }
        }
        let mut rom_count = 0;
        let rom_iter = match self.static_rom_image_index {
            None => std::iter::empty().collect::<Vec<_>>().into_iter(),
            Some((store, idx)) => {
                if store == Modes::RW as usize {
                    let mem_ro: FixedMemory<RO> = self.memory.frw_store[idx].clone().into();
                    mem_ro
                        .addr_val_bytes_iter()
                        .inspect(|_| rom_count += 1)
                        .map(map_to_mem_init_entry)
                        .collect::<Vec<_>>()
                        .into_iter()
                } else if store == Modes::RO as usize {
                    let mem_ro: FixedMemory<RO> = self.memory.fro_store[idx].clone();
                    mem_ro
                        .addr_val_bytes_iter()
                        .inspect(|_| rom_count += 1)
                        .map(map_to_mem_init_entry)
                        .collect::<Vec<_>>()
                        .into_iter()

Review comment (suggestion):
This should be `MemoryInitializationEntry::new()` per idiomatic Rust.

Code after:
                word.into_iter().enumerate().map(move |(j, byte)| {
                    MemoryInitializationEntry::new(base_address + j as u32, byte)
                })
            });

        let public_io_loc_iter = self
            .memory
            .segment_words(self.public_io_location_index, 0x80, None)
            .expect("Cannot find public io location in LinearEmulator")
            .iter()
            .enumerate()
            .flat_map(|(i, word_content)| {
                let base_address = 0x80 + i as u32 * WORD_SIZE as u32;
                let word = word_content.to_le_bytes();
                word.into_iter().enumerate().map(move |(j, byte)| {
                    MemoryInitializationEntry::new(base_address + j as u32, byte)
                })
            });

        let mut rom_count = 0;
        let rom_iter = match self.static_rom_image_index {
            None => std::iter::empty().collect::<Vec<_>>().into_iter(),
            Some((store, idx)) => match Modes::from_usize(store) {
                Some(Modes::RW) => {
                    let mem_ro: FixedMemory<RO> = self.memory.frw_store[idx].clone().into();
                    mem_ro
                        .addr_val_bytes_iter()
                        .inspect(|_| rom_count += 1)
                        .map(|(address, value)| MemoryInitializationEntry::new(address, value))
                        .collect::<Vec<_>>()
                        .into_iter()
                }
                Some(Modes::RO) => {
                    let mem_ro: FixedMemory<RO> = self.memory.fro_store[idx].clone();
                    mem_ro
                        .addr_val_bytes_iter()
                        .inspect(|_| rom_count += 1)
                        .map(|(address, value)| MemoryInitializationEntry::new(address, value))
                        .collect::<Vec<_>>()
                        .into_iter()
                }
                Some(Modes::WO) => {
                    let mem_na: FixedMemory<NA> = self.memory.fwo_store[idx].clone().into();
                    mem_na
                        .addr_val_bytes_iter()
                        .inspect(|_| rom_count += 1)
                        .map(|(address, value)| MemoryInitializationEntry::new(address, value))
                        .collect::<Vec<_>>()
                        .into_iter()
                }
                Some(Modes::NA) => {