Skip to main content

active_reporting/
mod.rs

1//^
2//^ HEAD
3//^
4
5//> HEAD -> NO STD
6#![no_std]
7
8//> HEAD -> DOCS
9#![doc = include_str!("README.md")]
10
11//> HEAD -> LINTS
12#![allow(incomplete_features)]
13
14//> HEAD -> FEATURES
15#![feature(const_trait_impl)]
16#![feature(const_convert)]
17#![feature(unsized_const_params)]
18#![feature(adt_const_params)]
19#![feature(negative_impls)]
20#![feature(const_heap)]
21#![feature(const_default)]
22#![feature(generic_const_exprs)]
23
24//> HEAD -> CRATES
25extern crate alloc;
26
27//> HEAD -> MODULES
28mod root;
29
30//> HEAD -> ROOT
31pub use root::Root;
32
33//> HEAD -> ALLOC
34use alloc::vec::Vec;
35
36//> HEAD -> CORE
37use core::{
38    ptr::NonNull,
39    ops::Deref
40};
41
42
43//^ 
44//^ REPORT
45//^ 
46
47//> REPORT -> STRUCT
48pub struct Report<const NAME: &'static str> {
49    chain: NonNull<Vec<&'static str>>,
50}
51
52//> REPORT -> IMPLEMENTATION
53impl<const NAME: &'static str> Report<NAME> {
54    pub const fn to<const OTHER: &'static str>(&mut self) -> Report<OTHER> {
55        if !OTHER.is_empty() {unsafe {self.chain.as_mut().push(OTHER)};}
56        return Report {
57            chain: self.chain
58        }
59    }
60}
61
62//> REPORT -> DROP
63impl<const NAME: &'static str> Drop for Report<NAME> {
64    fn drop(&mut self) {if !NAME.is_empty() {unsafe {self.chain.as_mut().pop()};}}
65}
66
67//> REPORT -> !SEND
68impl<const NAME: &'static str> !Send for Report<NAME> {}
69
70//> REPORT -> !SYNC
71impl<const NAME: &'static str> !Sync for Report<NAME> {}
72
73//> REPORT -> DEREF
74impl<const NAME: &'static str> Deref for Report<NAME> {
75    type Target = [&'static str];
76    fn deref(&self) -> &Self::Target {return unsafe {&self.chain.as_ref()}}
77}