cynic_parser_deser/value/
enums.rs

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
36
37
use cynic_parser::Span;

#[derive(Clone, Copy)]
pub struct EnumValue<'a> {
    pub(crate) name: &'a str,
    pub(crate) span: Option<Span>,
}

impl<'a> EnumValue<'a> {
    pub fn name(&self) -> &'a str {
        self.name
    }

    pub fn span(&self) -> Option<Span> {
        self.span
    }
}

impl PartialEq for EnumValue<'_> {
    fn eq(&self, other: &Self) -> bool {
        self.name() == other.name()
    }
}

impl Eq for EnumValue<'_> {}

impl std::fmt::Debug for EnumValue<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.name())
    }
}

impl std::fmt::Display for EnumValue<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.name())
    }
}