strafe_trait/
concept.rs

1use std::any::TypeId;
2
3pub trait Concept {
4    fn comparator(&self) -> TypeId
5    where
6        Self: 'static,
7    {
8        TypeId::of::<Self>()
9    }
10    fn new() -> Self
11    where
12        Self: Sized;
13}
14
15impl dyn Concept {
16    pub fn is<C: 'static + Concept>(&self) -> bool {
17        self.comparator() == C::new().comparator()
18    }
19}
20
21#[derive(Copy, Clone, Debug, PartialEq)]
22pub struct Normal {}
23
24impl Concept for Normal {
25    fn new() -> Self {
26        Self {}
27    }
28}
29
30#[derive(Copy, Clone, Debug, PartialEq)]
31pub struct NotNormal {}
32
33impl Concept for NotNormal {
34    fn new() -> Self {
35        Self {}
36    }
37}
38
39#[derive(Copy, Clone, Debug, PartialEq)]
40pub struct NormalResiduals {}
41
42impl Concept for NormalResiduals {
43    fn new() -> Self {
44        Self {}
45    }
46}
47
48#[derive(Copy, Clone, Debug, PartialEq)]
49pub struct NotNormalResiduals {}
50
51impl Concept for NotNormalResiduals {
52    fn new() -> Self {
53        Self {}
54    }
55}
56
57#[derive(Copy, Clone, Debug, PartialEq)]
58pub struct SomeSignficantFeature {}
59
60impl Concept for SomeSignficantFeature {
61    fn new() -> Self {
62        Self {}
63    }
64}
65
66#[derive(Copy, Clone, Debug, PartialEq)]
67pub struct NoSignificantFeature {}
68
69impl Concept for NoSignificantFeature {
70    fn new() -> Self {
71        Self {}
72    }
73}
74
75#[derive(Copy, Clone, Debug, PartialEq)]
76pub struct AccurateModel {}
77
78impl Concept for AccurateModel {
79    fn new() -> Self {
80        Self {}
81    }
82}
83
84#[derive(Copy, Clone, Debug, PartialEq)]
85pub struct InaccurateModel {}
86
87impl Concept for InaccurateModel {
88    fn new() -> Self {
89        Self {}
90    }
91}
92
93#[derive(Copy, Clone, Debug, PartialEq)]
94pub struct SignificantCoefficient {}
95
96impl Concept for SignificantCoefficient {
97    fn new() -> Self {
98        Self {}
99    }
100}
101
102#[derive(Copy, Clone, Debug, PartialEq)]
103pub struct InsignificantCoefficient {}
104
105impl Concept for InsignificantCoefficient {
106    fn new() -> Self {
107        Self {}
108    }
109}