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(default_field_values)]
16#![feature(const_heap)]
17#![feature(const_default)]
18#![feature(never_type)]
19#![feature(generic_const_exprs)]
20
21mod state;
23#[cfg(test)]
24mod tests;
25
26pub use state::{
28 Same,
29 Name
30};
31
32use state::{
34 State,
35 Main,
36 DerivedState
37};
38
39use issuing::Issue;
41
42use systemstd::System;
44
45use systemio::{
47 SystemIO,
48 Update
49};
50
51
52pub struct Report<Current: State> {
58 data: Current
59}
60
61impl Report<Main> {
63 pub const fn new(name: &'static str) -> Self {
64 let mut chain = Vec::new();
65 chain.push(name);
66 return Self {
67 data: Main {
68 chain: chain
69 }
70 };
71 }
72}
73
74impl<Current: const State> Report<Current> {
76 pub const fn to<'valid, Following: const DerivedState<'valid>>(&'valid mut self) -> Report<Following> {
77 return Report {
78 data: Following::convert(&mut self.data)
79 }
80 }
81 pub fn issue(&self, object: impl Into<Issue>) -> Option<!> {
82 System::problem(object.into(), self.data.get()).sync();
83 return None;
84 }
85 pub fn eat<Type>(&self, result: Result<Type, Issue>) -> Option<Type> {return match result {
86 Ok(value) => Some(value),
87 Err(issue) => self.issue(issue)?
88 }}
89}
90
91const impl Default for Report<Main> {
93 fn default() -> Self {return Self::new("Main")}
94}