use super::Report;
use core::{
ptr::NonNull,
ops::Deref
};
use alloc::vec::Vec;
pub struct Root {
chain: Vec<&'static str>
}
impl Root {
pub const fn new(name: &'static str) -> Self {return Self {
chain: if name.is_empty() {Vec::new()} else {
let mut chain = Vec::new();
chain.push(name);
chain
}
}}
pub const fn to<const NAME: &'static str>(&mut self) -> Report<NAME> {
if !NAME.is_empty() {self.chain.push(NAME);}
return Report {
chain: NonNull::new(&raw mut self.chain).unwrap()
}
}
}
const impl Default for Root {
fn default() -> Self {return Self::new("Main")}
}
impl !Sync for Root {}
const impl Deref for Root {
type Target = [&'static str];
fn deref(&self) -> &Self::Target {return &self.chain}
}