1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::fmt::{Display, Formatter};
use serde::Serialize;

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize)]
pub enum Keyword {
    SelfIdentifier,
    ThisFieldType,
}

impl Keyword {

    pub(crate) fn is_self(&self) -> bool {
        match self {
            Keyword::SelfIdentifier => true,
            _ => false,
        }
    }

    pub(crate) fn is_this_field_type(&self) -> bool {
        match self {
            Keyword::ThisFieldType => true,
            _ => false,
        }
    }
}

impl Display for Keyword {

    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Keyword::SelfIdentifier => f.write_str("Self"),
            Keyword::ThisFieldType => f.write_str("ThisFieldType"),
        }
    }
}