Skip to content

Commit

Permalink
Merge pull request #207 from niklasf/unsafe-from-bits-unchecked
Browse files Browse the repository at this point in the history
Document from_bits_unchecked unsafety (#200)
  • Loading branch information
KodrAus committed Jan 28, 2020
2 parents a755719 + e2270ec commit 15e911c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Expand Up @@ -637,6 +637,15 @@ macro_rules! __impl_bitflags {
__fn_bitflags! {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[inline]
pub const unsafe fn from_bits_unchecked(bits: $T) -> $BitFlags {
$BitFlags { bits }
Expand Down

0 comments on commit 15e911c

Please sign in to comment.