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 0f634f3 commit a2b18b5
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 a2b18b5

Please sign in to comment.