Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/bitflags/src/tests.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / bitflags / src / tests.rs` 161 lines · 3370 bytes Raw Blame History 1 mod all; 2 mod all_named; 3 mod bitflags_match; 4 mod bits; 5 mod clear; 6 mod complement; 7 mod contains; 8 mod difference; 9 mod empty; 10 mod eq; 11 mod extend; 12 mod flag_name; 13 mod flags; 14 mod fmt; 15 mod from_bits; 16 mod from_bits_retain; 17 mod from_bits_truncate; 18 mod from_name; 19 mod insert; 20 mod intersection; 21 mod intersects; 22 mod is_all; 23 mod is_empty; 24 mod iter; 25 mod iter_equal_names; 26 mod known_bits; 27 mod parser; 28 mod remove; 29 mod symmetric_difference; 30 mod truncate; 31 mod union; 32 mod unknown; 33 mod unknown_bits; 34 35 mod custom { 36 pub const NAME: &'static str = "custom"; 37 } 38 39 bitflags! { 40 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 41 pub struct TestFlags: u8 { 42 /// 1 43 const A = 1; 44 45 /// 1 << 1 46 const B = 1 << 1; 47 48 /// 1 << 2 49 const C = 1 << 2; 50 51 /// 1 | (1 << 1) | (1 << 2) 52 const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); 53 } 54 55 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 56 pub struct TestFlagsInvert: u8 { 57 /// 1 | (1 << 1) | (1 << 2) 58 const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); 59 60 /// 1 61 const A = 1; 62 63 /// 1 << 1 64 const B = 1 << 1; 65 66 /// 1 << 2 67 const C = 1 << 2; 68 } 69 70 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 71 pub struct TestZero: u8 { 72 /// 0 73 const ZERO = 0; 74 } 75 76 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 77 pub struct TestZeroOne: u8 { 78 /// 0 79 const ZERO = 0; 80 81 /// 1 82 const ONE = 1; 83 } 84 85 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 86 pub struct TestUnicode: u8 { 87 /// 1 88 const 一 = 1; 89 90 /// 2 91 const 二 = 1 << 1; 92 } 93 94 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 95 pub struct TestEmpty: u8 {} 96 97 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 98 pub struct TestOverlapping: u8 { 99 /// 1 | (1 << 1) 100 const AB = 1 | (1 << 1); 101 102 /// (1 << 1) | (1 << 2) 103 const BC = (1 << 1) | (1 << 2); 104 } 105 106 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 107 pub struct TestOverlappingFull: u8 { 108 /// 1 109 const A = 1; 110 111 /// 1 112 const B = 1; 113 114 /// 1 115 const C = 1; 116 117 /// 2 118 const D = 1 << 1; 119 } 120 121 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 122 pub struct TestExternal: u8 { 123 /// 1 124 const A = 1; 125 126 /// 1 << 1 127 const B = 1 << 1; 128 129 /// 1 << 2 130 const C = 1 << 2; 131 132 /// 1 | (1 << 1) | (1 << 2) 133 const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); 134 135 /// External 136 const _ = !0; 137 } 138 139 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 140 pub struct TestExternalFull: u8 { 141 /// External 142 const _ = !0; 143 } 144 145 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] 146 pub struct TestRenamed: u8 { 147 /// 1 148 #[bitflags(flag_name = "a")] 149 #[bitflags(flag_name = custom::NAME)] 150 const A = 1; 151 /// 1 << 1 152 #[bitflags(flag_name = "custom")] 153 const B = 1 << 1; 154 /// 1 << 2 155 #[bitflags(flag_name = "c")] 156 const C = 1 << 2; 157 /// 1 << 3 158 #[bitflags(flag_name = "custom | e")] 159 const D = 1 << 3; 160 } 161 }