1#![allow(incomplete_features)]
7
8#![feature(const_trait_impl)]
10#![feature(unsized_const_params)]
11#![feature(adt_const_params)]
12#![feature(default_field_values)]
13#![feature(const_heap)]
14#![feature(const_default)]
15#![feature(never_type)]
16#![feature(generic_const_exprs)]
17
18mod state;
20#[cfg(test)]
21mod tests;
22
23pub use state::{
25 Same,
26 Name
27};
28
29use state::{
31 State,
32 Main,
33 DerivedState
34};
35
36use libutils_issue::Issue;
38
39use libutils_terminal::Terminal;
41
42use libutils_console::{
44 Console,
45 Update
46};
47
48
49pub struct Report<Current: State> {
55 data: Current
56}
57
58impl Report<Main> {
60 pub const fn new(name: &'static str) -> Self {
61 let mut chain = Vec::new();
62 chain.push(name);
63 return Self {
64 data: Main {
65 chain: chain
66 }
67 };
68 }
69}
70
71impl<Current: const State> Report<Current> {
73 pub const fn to<'valid, Following: const DerivedState<'valid>>(&'valid mut self) -> Report<Following> {
74 return Report {
75 data: Following::convert(&mut self.data)
76 }
77 }
78 pub fn issue(&self, object: impl Into<Issue>) -> Option<!> {
79 Terminal.problem(object.into(), self.data.get()).sync();
80 return None;
81 }
82 pub fn eat<Type>(&self, result: Result<Type, Issue>) -> Option<Type> {return match result {
83 Ok(value) => Some(value),
84 Err(issue) => self.issue(issue)?
85 }}
86}
87
88const impl Default for Report<Main> {
90 fn default() -> Self {return Self::new("Main")}
91}