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