mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-12-25 13:41:07 +00:00
21 lines
402 B
Rust
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![])
|
||
|
}
|
||
|
}
|