1use crate::Index;
2use std::fmt::Debug;
3use std::hash::Hash;
4
5pub trait Label
7where
8 Self: Sized + Copy + Eq + Hash + Debug,
9{
10 type Index: Eq + Copy + Hash + Debug + Index + 'static;
12
13 fn variants() -> &'static [Self];
15
16 fn indexes(&self) -> &'static [Self::Index];
18
19 fn ordinal(&self) -> usize;
21
22 fn name(&self) -> &'static str;
24}
25
26impl Label for () {
27 type Index = ();
28
29 fn variants() -> &'static [Self] {
31 &[()]
32 }
33
34 fn indexes(&self) -> &'static [Self::Index] {
35 &[]
36 }
37
38 fn ordinal(&self) -> usize {
39 0
40 }
41
42 fn name(&self) -> &'static str {
43 "<anonymous>"
44 }
45}