1use super::Report;
7
8use core::{
10 ptr::NonNull,
11 ops::Deref
12};
13
14use alloc::vec::Vec;
16
17
18pub struct Root {
24 chain: Vec<&'static str>
25}
26
27impl Root {
29 pub const fn new(name: &'static str) -> Self {return Self {
30 chain: if name.is_empty() {Vec::new()} else {
31 let mut chain = Vec::new();
32 chain.push(name);
33 chain
34 }
35 }}
36 pub const fn to<const NAME: &'static str>(&mut self) -> Report<NAME> {
37 if !NAME.is_empty() {self.chain.push(NAME);}
38 return Report {
39 chain: NonNull::new(&raw mut self.chain).unwrap()
40 }
41 }
42}
43
44const impl Default for Root {
46 fn default() -> Self {return Self::new("Main")}
47}
48
49impl !Sync for Root {}
51
52const impl Deref for Root {
54 type Target = [&'static str];
55 fn deref(&self) -> &Self::Target {return &self.chain}
56}