2020-06-06 11:57:24 -07:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct LogCollector {
|
|
|
|
messages: RefCell<Vec<String>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl LogCollector {
|
|
|
|
pub fn log(&self, message: &str) {
|
|
|
|
self.messages.borrow_mut().push(message.to_string())
|
|
|
|
}
|
2020-08-25 21:09:24 +00:00
|
|
|
}
|
|
|
|
impl Into<Vec<String>> for LogCollector {
|
|
|
|
fn into(self) -> Vec<String> {
|
2020-06-06 11:57:24 -07:00
|
|
|
self.messages.into_inner()
|
|
|
|
}
|
|
|
|
}
|