Skip to content

Commit

Permalink
feat: Make set, unset and toggle const
Browse files Browse the repository at this point in the history
Rust 1.75.0 allows us to make functions with `&mut` const
  • Loading branch information
GrayJack committed Nov 19, 2024
1 parent 9f698b6 commit 0078bcf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,20 +596,20 @@ fn bitflag_impl(attr: TokenStream, item: TokenStream) -> Result<TokenStream> {
/// Set the flags in `other` in the value.
#[inline]
#[doc(alias = "insert")]
pub fn set(&mut self, other: Self) {
pub const fn set(&mut self, other: Self) {
self.0 = self.or(other).0
}

/// Unset the flags in `other` in the value.
#[inline]
#[doc(alias = "remove")]
pub fn unset(&mut self, other: Self) {
pub const fn unset(&mut self, other: Self) {
self.0 = self.difference(other).0
}

/// Toggle the flags in `other` in the value.
#[inline]
pub fn toggle(&mut self, other: Self) {
pub const fn toggle(&mut self, other: Self) {
self.0 = self.xor(other).0
}
}
Expand Down

0 comments on commit 0078bcf

Please sign in to comment.