openpql_pql_parser/ast/
selector_kind.rs1use super::fmt;
2
3#[derive(Clone, Copy, PartialEq, Eq, derive_more::Debug)]
5pub enum SelectorKind {
6 #[debug("avg")]
8 Avg,
9 #[debug("count")]
11 Count,
12 #[debug("max")]
14 Max,
15 #[debug("min")]
17 Min,
18}
19
20impl fmt::Display for SelectorKind {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match *self {
23 Self::Avg => f.write_str("AVG"),
24 Self::Count => f.write_str("COUNT"),
25 Self::Max => f.write_str("MAX"),
26 Self::Min => f.write_str("MIN"),
27 }
28 }
29}
30
31#[cfg(test)]
32mod tests {
33 use super::*;
34
35 #[test]
36 fn test_display() {
37 assert_eq!(SelectorKind::Avg.to_string(), "AVG");
38 assert_eq!(SelectorKind::Count.to_string(), "COUNT");
39 assert_eq!(SelectorKind::Max.to_string(), "MAX");
40 assert_eq!(SelectorKind::Min.to_string(), "MIN");
41 }
42}