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