Loading RustViz Engine...
Mutate inner state behind an immutable reference and handle BorrowError at runtime.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
use std::cell::RefCell;
pub struct Logger {
logs: RefCell<Vec<String>>,
}
impl Logger {
pub fn new() -> Self { Self { logs: RefCell::new(Vec::new()) } }
pub fn log(&self, msg: &str) {
self.logs.borrow_mut().push(msg.to_string());
}
}