currently I'm trying to debug a problem but in order to do that I'm trying to print out some information so I figured I would go and implement Display for my BufferMemory. I keep getting std::option::Option<&memory::BufferMemory>` doesn't implement `std::fmt::Display
std::option::Option<&memory::BufferMemory>` cannot be formatted with the default formatter
even though I'm pretty sure I've implemented it here. What could I be doing wrong?
/// A simple buffer of memory for MemorySystem
#[derive(Default)]
pub struct BufferMemory{
pub memory: Vec<u8>,
}
impl fmt::Display for BufferMemory {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let formatted_vec = String::from_utf8(self.memory).unwrap();
write!(f, "{}", formatted_vec)
}
}
/// The system for tracking all memory within the VM
#[derive(Default)]
pub struct MemorySystem{
map: HashMap<u32, BufferMemory>
}
and I'm trying to access the value I'm looking at like such.
println!("result: {}", self.map.get(&(address & 0xFFFF0000)));
where address is a u32 value
User contributions licensed under CC BY-SA 3.0