1#![doc = include_str!("README.md")]
7
8#![allow(incomplete_features)]
10
11#![feature(const_trait_impl)]
13#![feature(unsized_const_params)]
14#![feature(adt_const_params)]
15#![feature(phantom_variance_markers)]
16#![feature(negative_impls)]
17#![feature(const_heap)]
18#![feature(const_default)]
19#![feature(generic_const_exprs)]
20
21mod root;
23
24pub use root::Root;
26
27use core::{
29 marker::PhantomCovariantLifetime,
30 ptr::NonNull
31};
32
33
34pub struct Report<'valid, const NAME: &'static str> {
40 chain: NonNull<Vec<&'static str>>,
41 _lifetime: PhantomCovariantLifetime<'valid>
42}
43
44impl<'valid, const NAME: &'static str> Report<'valid, NAME> {
46 pub const fn chain(&'valid self) -> &'valid [&'static str] {
47 return unsafe {self.chain.as_ref().as_slice()};
48 }
49 pub const fn to<const OTHER: &'static str>(&'valid mut self) -> Report<'valid, OTHER> {
50 if !OTHER.is_empty() {unsafe {self.chain.as_mut().push(OTHER)};}
51 return Report {
52 chain: self.chain,
53 _lifetime: PhantomCovariantLifetime::new()
54 }
55 }
56}
57
58impl<'valid, const NAME: &'static str> Drop for Report<'valid, NAME> {
60 fn drop(&mut self) {if !NAME.is_empty() {unsafe {self.chain.as_mut().pop()};}}
61}
62
63impl<'valid, const NAME: &'static str> !Send for Report<'valid, NAME> {}
65
66impl<'valid, const NAME: &'static str> !Sync for Report<'valid, NAME> {}