Warning

"unused variable" — How to Fix or Suppress

Fix the unused variable warning by wrapping the mutable vector in a RefCell to allow interior mutability within the Messenger trait implementation.

The warning occurs because the send method in your Messenger trait implementation takes &self but attempts to mutate sent_messages without interior mutability. Wrap the Vec in a RefCell and borrow it mutably inside the method.

use std::cell::RefCell;

struct MockMessenger {
    sent_messages: RefCell<Vec<String>>,
}

impl Messenger for MockMessenger {
    fn send(&self, message: &str) {
        self.sent_messages.borrow_mut().push(String::from(message));
    }
}