rs_teststand/expression/function/
numeric.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum NumericFunction {
8 Abs,
10 ACos,
12 Asc,
14 ASin,
16 ATan,
18 Cos,
20 Exp,
22 Float64,
24 Int64,
26 Log,
28 Log10,
30 Max,
32 Min,
34 Pow,
36 Random,
38 Round,
40 Sin,
42 Sqrt,
44 Tan,
46 UInt64,
48 Val,
50}
51
52impl NumericFunction {
53 pub const ALL: [Self; 21] = [
55 Self::Abs,
56 Self::ACos,
57 Self::Asc,
58 Self::ASin,
59 Self::ATan,
60 Self::Cos,
61 Self::Exp,
62 Self::Float64,
63 Self::Int64,
64 Self::Log,
65 Self::Log10,
66 Self::Max,
67 Self::Min,
68 Self::Pow,
69 Self::Random,
70 Self::Round,
71 Self::Sin,
72 Self::Sqrt,
73 Self::Tan,
74 Self::UInt64,
75 Self::Val,
76 ];
77
78 #[must_use]
80 pub const fn name(self) -> &'static str {
81 match self {
82 Self::Abs => "Abs",
83 Self::ACos => "ACos",
84 Self::Asc => "Asc",
85 Self::ASin => "ASin",
86 Self::ATan => "ATan",
87 Self::Cos => "Cos",
88 Self::Exp => "Exp",
89 Self::Float64 => "Float64",
90 Self::Int64 => "Int64",
91 Self::Log => "Log",
92 Self::Log10 => "Log10",
93 Self::Max => "Max",
94 Self::Min => "Min",
95 Self::Pow => "Pow",
96 Self::Random => "Random",
97 Self::Round => "Round",
98 Self::Sin => "Sin",
99 Self::Sqrt => "Sqrt",
100 Self::Tan => "Tan",
101 Self::UInt64 => "UInt64",
102 Self::Val => "Val",
103 }
104 }
105}
106
107#[cfg(test)]
108mod tests {
109 use super::NumericFunction;
110
111 #[test]
112 fn every_name_is_distinct() {
113 let mut names: Vec<&str> = NumericFunction::ALL.iter().map(|f| f.name()).collect();
114 names.sort_unstable();
115 let count = names.len();
116 names.dedup();
117 assert_eq!(names.len(), count);
118 }
119}