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
/// Error level of the diagnostic message
#[repr(C)]
#[derive(Clone, PartialEq, Eq)]
pub enum ErrorLevel {
    /// Warning level
    Warning,
    /// Error level
    Error,
}

impl ErrorLevel {
    /// Constructs a warning
    pub fn warning() -> Self {
        Self::Warning
    }

    /// Constructs an error
    pub fn error() -> Self {
        Self::Error
    }

    /// Returns true if `self` is a warning
    pub fn is_warning(&self) -> bool {
        matches!(self, Self::Warning)
    }

    /// Returns true if `self` is an error
    pub fn is_error(&self) -> bool {
        matches!(self, Self::Error)
    }
}