meta_language/
link_flags.rs1#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
3pub struct LinkFlags {
4 bits: u8,
5}
6
7impl LinkFlags {
8 const IS_ERROR: u8 = 0b0001;
9 const HAS_ERROR: u8 = 0b0010;
10 const IS_MISSING: u8 = 0b0100;
11 const IS_EXTRA: u8 = 0b1000;
12
13 #[must_use]
15 pub const fn clean() -> Self {
16 Self { bits: 0 }
17 }
18
19 #[must_use]
21 pub const fn error() -> Self {
22 Self {
23 bits: Self::IS_ERROR,
24 }
25 }
26
27 #[must_use]
29 pub const fn containing_error() -> Self {
30 Self {
31 bits: Self::HAS_ERROR,
32 }
33 }
34
35 #[must_use]
37 pub const fn missing() -> Self {
38 Self {
39 bits: Self::IS_MISSING,
40 }
41 }
42
43 #[must_use]
45 pub const fn extra() -> Self {
46 Self {
47 bits: Self::IS_EXTRA,
48 }
49 }
50
51 #[must_use]
53 pub const fn is_error(self) -> bool {
54 self.bits & Self::IS_ERROR != 0
55 }
56
57 #[must_use]
59 pub const fn has_error(self) -> bool {
60 self.bits & Self::HAS_ERROR != 0
61 }
62
63 #[must_use]
65 pub const fn is_missing(self) -> bool {
66 self.bits & Self::IS_MISSING != 0
67 }
68
69 #[must_use]
71 pub const fn is_extra(self) -> bool {
72 self.bits & Self::IS_EXTRA != 0
73 }
74}