1use super::Report;
7
8use core::{
10 ptr::NonNull,
11 marker::PhantomCovariantLifetime
12};
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<'valid, const NAME: &'static str>(&'valid mut self) -> Report<'valid, NAME> {
35 if !NAME.is_empty() {self.chain.push(NAME);}
36 return Report {
37 chain: NonNull::new(&raw mut self.chain).unwrap(),
38 _lifetime: PhantomCovariantLifetime::new()
39 }
40 }
41}
42
43const impl Default for Root {
45 fn default() -> Self {return Self::new("Main")}
46}
47
48impl !Sync for Root {}