1pub const trait State {
7 fn get<'valid>(&'valid self) -> &'valid Vec<&'static str>;
8 fn get_mut<'valid>(&'valid mut self) -> &'valid mut Vec<&'static str>;
9}
10
11pub const trait DerivedState<'valid>: const State + const Convert<'valid> {}
13
14pub const trait Convert<'valid> {
16 fn convert<Current: const State>(value: &'valid mut Current) -> Self;
17}
18
19
20pub struct Main {
26 pub chain: Vec<&'static str> = Vec::new()
27}
28
29const impl State for Main {
31 fn get<'valid>(&'valid self) -> &'valid Vec<&'static str> {return &self.chain}
32 fn get_mut<'valid>(&'valid mut self) -> &'valid mut Vec<&'static str> {return &mut self.chain}
33}
34
35
36pub struct Same<'this> {
42 link: &'this mut Vec<&'static str>
43}
44
45const impl<'this> State for Same<'this> {
47 fn get<'valid>(&'valid self) -> &'valid Vec<&'static str> {return self.link}
48 fn get_mut<'valid>(&'valid mut self) -> &'valid mut Vec<&'static str> {return self.link}
49}
50
51const impl<'valid> DerivedState<'valid> for Same<'valid> {}
53
54const impl<'valid> Convert<'valid> for Same<'valid> {
56 fn convert<Current: const State>(value: &'valid mut Current) -> Self {
57 return Self {
58 link: value.get_mut()
59 }
60 }
61}
62
63
64pub struct Name<'valid, const NAME: &'static str> {
70 link: &'valid mut Vec<&'static str>
71}
72
73const impl<'this, const NAME: &'static str> State for Name<'this, NAME> {
75 fn get<'valid>(&'valid self) -> &'valid Vec<&'static str> {return self.link}
76 fn get_mut<'valid>(&'valid mut self) -> &'valid mut Vec<&'static str> {return self.link}
77}
78
79impl<'valid, const NAME: &'static str> Drop for Name<'valid, NAME> {
81 fn drop(&mut self) {self.link.pop();}
82}
83
84const impl<'valid, const NAME: &'static str> DerivedState<'valid> for Name<'valid, NAME> {}
86
87const impl<'valid, const NAME: &'static str> Convert<'valid> for Name<'valid, NAME> {
89 fn convert<Current: const State>(value: &'valid mut Current) -> Self {
90 let link = value.get_mut();
91 link.push(NAME);
92 return Self {
93 link: link
94 }
95 }
96}