use super::Report;
use core::{
ptr::NonNull,
marker::PhantomCovariantLifetime
};
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 chain(&self) -> &[&'static str] {return self.chain.as_slice()}
pub const fn to<'valid, 'next, const NAME: &'static str>(&'valid mut self) -> Report<'next, NAME> where 'valid: 'next {
if !NAME.is_empty() {self.chain.push(NAME);}
return Report {
chain: NonNull::new(&raw mut self.chain).unwrap(),
_lifetime: PhantomCovariantLifetime::new()
}
}
}
const impl Default for Root {
fn default() -> Self {return Self::new("Main")}
}
impl !Sync for Root {}