aboutsummaryrefslogtreecommitdiff
path: root/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs')
-rw-r--r--vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs123
1 files changed, 123 insertions, 0 deletions
diff --git a/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs b/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs
new file mode 100644
index 0000000..c2856b1
--- /dev/null
+++ b/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs
@@ -0,0 +1,123 @@
+use std::{
+ fmt::{
+ self,
+ Debug,
+ Display,
+ LowerHex,
+ UpperHex,
+ Octal,
+ Binary,
+ },
+ ops::{
+ BitAnd,
+ BitOr,
+ BitXor,
+ BitAndAssign,
+ BitOrAssign,
+ BitXorAssign,
+ Not,
+ },
+};
+
+use bitflags::bitflags;
+
+// Ideally we'd actually want this to work, but currently need something like `num`'s `Zero`
+// With some design work it could be made possible
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+struct MyInt(u8);
+
+impl BitAnd for MyInt {
+ type Output = Self;
+
+ fn bitand(self, other: Self) -> Self {
+ MyInt(self.0 & other.0)
+ }
+}
+
+impl BitOr for MyInt {
+ type Output = Self;
+
+ fn bitor(self, other: Self) -> Self {
+ MyInt(self.0 | other.0)
+ }
+}
+
+impl BitXor for MyInt {
+ type Output = Self;
+
+ fn bitxor(self, other: Self) -> Self {
+ MyInt(self.0 ^ other.0)
+ }
+}
+
+impl BitAndAssign for MyInt {
+ fn bitand_assign(&mut self, other: Self) {
+ self.0 &= other.0
+ }
+}
+
+impl BitOrAssign for MyInt {
+ fn bitor_assign(&mut self, other: Self) {
+ self.0 |= other.0
+ }
+}
+
+impl BitXorAssign for MyInt {
+ fn bitxor_assign(&mut self, other: Self) {
+ self.0 ^= other.0
+ }
+}
+
+impl Debug for MyInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ Debug::fmt(&self.0, f)
+ }
+}
+
+impl Display for MyInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ Display::fmt(&self.0, f)
+ }
+}
+
+impl LowerHex for MyInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ LowerHex::fmt(&self.0, f)
+ }
+}
+
+impl UpperHex for MyInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ UpperHex::fmt(&self.0, f)
+ }
+}
+
+impl Octal for MyInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ Octal::fmt(&self.0, f)
+ }
+}
+
+impl Binary for MyInt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ Binary::fmt(&self.0, f)
+ }
+}
+
+impl Not for MyInt {
+ type Output = MyInt;
+
+ fn not(self) -> Self {
+ MyInt(!self.0)
+ }
+}
+
+bitflags! {
+ struct Flags128: MyInt {
+ const A = MyInt(0b0000_0001u8);
+ const B = MyInt(0b0000_0010u8);
+ const C = MyInt(0b0000_0100u8);
+ }
+}
+
+fn main() {}