diff --git a/src/types.rs b/src/types.rs index d1500cc..7c73770 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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 for $name