tree_automata/
label.rs

1use std::hash::Hash;
2use std::fmt;
3
4#[cfg(not(debug_assertions))]
5pub trait Label = Hash + Clone + Eq;
6
7#[cfg(debug_assertions)]
8pub trait Label = Hash + Clone + Eq + fmt::Display + fmt::Debug;
9
10// impl Label for () {}
11// impl Label for String {}
12// impl<'a> Label for &'a str {}
13// impl Label for char {}
14// impl Label for bool {}
15// impl Label for u8 {}
16// impl Label for u16 {}
17// impl Label for u32 {}
18// impl Label for u64 {}
19// impl Label for i8 {}
20// impl Label for i16 {}
21// impl Label for i32 {}
22// impl Label for i64 {}
23
24pub type Labeled<T, L> = (T, L);
25
26#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
27pub struct NoLabel;
28
29impl fmt::Display for NoLabel {
30    fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
31        Ok(())
32    }
33}
34
35// impl<T, L: Label> Labeled<T, L> {
36//     pub fn new(t: T, label: L) -> Labeled<T, L> {
37//         Labeled {
38//             t: t,
39//             label: label
40//         }
41//     }
42// }
43//
44// impl<T: Clone, L: Label> Clone for Labeled<T, L> {
45//     fn clone(&self) -> Self {
46//         Labeled {
47//             t: self.t.clone(),
48//             label: self.label.clone()
49//         }
50//     }
51// }
52//
53// impl<T: Hash, L: Label> Hash for Labeled<T, L> {
54//     fn hash<H: Hasher>(&self, state: &mut H) {
55//         self.t.hash(state);
56//         self.label.hash(state);
57//     }
58// }
59//
60// impl<T: PartialEq, L: Label> PartialEq for Labeled<T, L> {
61//     fn eq(&self, other: &Labeled<T, L>) -> bool {
62//         self.label == other.label && self.t == other.t
63//     }
64// }
65//
66// impl<T: Eq, L: Label> Eq for Labeled<T, L> { }