salsa/tests/gc/log.rs
2018-10-25 08:41:26 -04:00

21 lines
402 B
Rust

use std::cell::RefCell;
pub(crate) trait HasLog {
fn log(&self) -> &Log;
}
#[derive(Default)]
pub(crate) struct Log {
data: RefCell<Vec<String>>,
}
impl Log {
pub(crate) fn add(&self, text: impl Into<String>) {
self.data.borrow_mut().push(text.into());
}
pub(crate) fn take(&self) -> Vec<String> {
std::mem::replace(&mut *self.data.borrow_mut(), vec![])
}
}