mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Support all bitwise operations on flags
This commit is contained in:
@@ -63,6 +63,12 @@ macro_rules! flag_type(
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Not<$typename> for $typename {
|
||||
fn not(&self) -> $typename {
|
||||
$typename { bits: !self.bits }
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::BitAnd<$typename, $typename> for $typename {
|
||||
fn bitand(&self, rhs: &$typename) -> $typename {
|
||||
$typename { bits: self.bits & rhs.bits }
|
||||
@@ -81,6 +87,18 @@ macro_rules! flag_type(
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Shl<u32, $typename> for $typename {
|
||||
fn shl(&self, rhs: &u32) -> $typename {
|
||||
$typename { bits: self.bits << *rhs }
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Shr<u32, $typename> for $typename {
|
||||
fn shr(&self, rhs: &u32) -> $typename {
|
||||
$typename { bits: self.bits >> *rhs }
|
||||
}
|
||||
}
|
||||
|
||||
$(
|
||||
pub static $name: $typename = $typename { bits: $value };
|
||||
)+
|
||||
|
||||
Reference in New Issue
Block a user