runmat_runtime/
warning_store.rs1use std::cell::RefCell;
2
3#[derive(Clone, Debug)]
4pub struct RuntimeWarning {
5 pub identifier: String,
6 pub message: String,
7}
8
9thread_local! {
10 static WARNINGS: RefCell<Vec<RuntimeWarning>> = const { RefCell::new(Vec::new()) };
11}
12
13pub fn push(identifier: &str, message: &str) {
14 WARNINGS.with(|warnings| {
15 warnings.borrow_mut().push(RuntimeWarning {
16 identifier: identifier.to_string(),
17 message: message.to_string(),
18 })
19 });
20}
21
22pub fn take_all() -> Vec<RuntimeWarning> {
23 WARNINGS.with(|warnings| warnings.borrow_mut().drain(..).collect())
24}
25
26pub fn reset() {
27 WARNINGS.with(|warnings| warnings.borrow_mut().clear());
28}