openpql_pql_parser/ast/
selector_kind.rs

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