1use super::Report;
7
8use core::ptr::NonNull;
10
11use alloc::vec::Vec;
13
14
15pub struct Root {
21 chain: Vec<&'static str>
22}
23
24impl Root {
26 pub const fn new(name: &'static str) -> Self {return Self {
27 chain: if name.is_empty() {Vec::new()} else {
28 let mut chain = Vec::new();
29 chain.push(name);
30 chain
31 }
32 }}
33 pub const fn chain(&self) -> &[&'static str] {return self.chain.as_slice()}
34 pub const fn to<const NAME: &'static str>(&mut self) -> Report<NAME> {
35 if !NAME.is_empty() {self.chain.push(NAME);}
36 return Report {
37 chain: NonNull::new(&raw mut self.chain).unwrap()
38 }
39 }
40}
41
42const impl Default for Root {
44 fn default() -> Self {return Self::new("Main")}
45}
46
47impl !Sync for Root {}