Skip to content

Commit

Permalink
Merge pull request #218 from hannobraun/bitflags
Browse files Browse the repository at this point in the history
Add wrapper functions to `bitflags` types
  • Loading branch information
hannobraun authored Aug 13, 2024
2 parents 0f634f3 + a2b18b5 commit d6d1454
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,19 @@ bitflags! {
}
}

impl EventMask {
/// Wrapper around [`Self::from_bits_retain`] for backwards compatibility
///
/// # Safety
///
/// This function is not actually unsafe. It is just a wrapper around the
/// safe [`Self::from_bits_retain`].
#[deprecated = "Use the safe `from_bits_retain` method instead"]
pub unsafe fn from_bits_unchecked(bits: u32) -> Self {
Self::from_bits_retain(bits)
}
}


#[cfg(test)]
mod tests {
Expand Down
13 changes: 13 additions & 0 deletions src/watches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ bitflags! {
}
}

impl WatchMask {
/// Wrapper around [`Self::from_bits_retain`] for backwards compatibility
///
/// # Safety
///
/// This function is not actually unsafe. It is just a wrapper around the
/// safe [`Self::from_bits_retain`].
#[deprecated = "Use the safe `from_bits_retain` method instead"]
pub unsafe fn from_bits_unchecked(bits: u32) -> Self {
Self::from_bits_retain(bits)
}
}

impl WatchDescriptor {
/// Getter method for a watcher's id.
///
Expand Down

0 comments on commit d6d1454

Please sign in to comment.