Rust: Implemented Display on Formatter for BufferMemory but for some reason won't take


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
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
pub struct MemorySystem{
    map: HashMap<u32, BufferMemory>

and I'm trying to access the value I'm looking at like such.

        println!("result: {}", & 0xFFFF0000)));

where address is a u32 value

asked on Stack Overflow Feb 6, 2020 by Richard John Catalano • edited Feb 6, 2020 by Richard John Catalano

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0