fix janky bitflags hack

master
Avril 4 years ago
parent f79f186dc5
commit 8f7110bf39
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -61,7 +61,7 @@ macro_rules! enum_flags {
}) => {
#[repr(transparent)] //this seems dodgy to me
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Default, Copy)] //this has to be copy for the assignments to be ergonomic :/
pub struct $name(libc::c_int);
impl $name {
@ -73,15 +73,25 @@ macro_rules! enum_flags {
{
Self(int)
}
pub const fn as_int(&self) -> libc::c_int
pub const fn as_int(self) -> libc::c_int
{
self.0
}
pub const fn has(&self, other: &Self) -> bool
pub const fn has(self, other: Self) -> bool
{
(self.0 & other.0) == other.0
}
pub const fn add(self, other: Self) -> Self
{
Self(self.0 | other.0)
}
pub const fn remove(self, other: Self) -> Self
{
Self((self.0 | other.0) ^ other.0)
}
}
impl From<libc::c_int> for $name

Loading…
Cancel
Save