Skip to main content

active_reporting/
mod.rs

1//^
2//^ HEAD
3//^
4
5//> HEAD -> DOCS
6#![doc = include_str!("README.md")]
7
8//> HEAD -> LINTS
9#![allow(incomplete_features)]
10
11//> HEAD -> FEATURES
12#![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
21//> HEAD -> MODULES
22mod root;
23
24//> HEAD -> ROOT
25pub use root::Root;
26
27//> HEAD -> CORE
28use core::{
29    marker::PhantomCovariantLifetime,
30    ptr::NonNull
31};
32
33
34//^ 
35//^ REPORT
36//^ 
37
38//> REPORT -> STRUCT
39pub struct Report<'valid, const NAME: &'static str> {
40    chain: NonNull<Vec<&'static str>>,
41    _lifetime: PhantomCovariantLifetime<'valid>
42}
43
44//> REPORT -> IMPLEMENTATION
45impl<'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
58//> REPORT -> DROP
59impl<'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
63//> REPORT -> !SEND
64impl<'valid, const NAME: &'static str> !Send for Report<'valid, NAME> {}
65
66//> REPORT -> !SYNC
67impl<'valid, const NAME: &'static str> !Sync for Report<'valid, NAME> {}