Skip to main content

luaur_analysis/records/
error_suppression.rs

1use crate::enums::value::Value;
2
3#[allow(non_camel_case_types)]
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub struct ErrorSuppression {
6    pub(crate) value: Value,
7}
8
9#[allow(non_snake_case)]
10impl ErrorSuppression {
11    pub const fn new() -> Self {
12        Self {
13            value: Value::Suppress,
14        }
15    }
16
17    pub const fn from_value(enum_value: Value) -> Self {
18        Self { value: enum_value }
19    }
20
21    pub fn or_else(&self, other: &Self) -> Self {
22        match self.value {
23            Value::DoNotSuppress => *other,
24            _ => *self,
25        }
26    }
27}
28
29impl Default for ErrorSuppression {
30    fn default() -> Self {
31        Self {
32            value: Value::Suppress,
33        }
34    }
35}
36
37impl From<ErrorSuppression> for Value {
38    fn from(suppression: ErrorSuppression) -> Self {
39        suppression.value
40    }
41}
42
43impl From<Value> for ErrorSuppression {
44    fn from(value: Value) -> Self {
45        Self { value }
46    }
47}
48
49unsafe impl Send for ErrorSuppression {}
50unsafe impl Sync for ErrorSuppression {}