Skip to content

Commit

Permalink
Add wrapper functions to bitflags types
Browse files Browse the repository at this point in the history
This reduces potential breakage for users of this library.

See https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md#200 for
context.
  • Loading branch information
hannobraun committed Aug 13, 2024
1 parent 90defd7 commit 22de2b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ bitflags! {
}
}

impl EventMask {
/// Wrapper around `from_bits_retain` for backwards compatibility
#[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
8 changes: 8 additions & 0 deletions src/watches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ bitflags! {
}
}

impl WatchMask {
/// Wrapper around `from_bits_retain` for backwards compatibility
#[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 22de2b0

Please sign in to comment.