From e2270ecd3979ac83ac8d98ad048a25fb9d49aef1 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Wed, 22 Jan 2020 12:51:49 +0100 Subject: [PATCH] Document from_bits_unchecked unsafety (#200) --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b8568ad7..55daa5ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 }