diff options
author | Ashley Mannix <ashleymannix@live.com.au> | 2020-01-28 11:51:36 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 11:51:36 +1000 |
commit | 15e911c304d5bd8805af55d7e4f8c5324ed798ee (patch) | |
tree | e7ab1cda787116be024bc6a87ca769069004ab2c | |
parent | a755719edc3636b167598f06d4715f9bb582b0f2 (diff) | |
parent | e2270ecd3979ac83ac8d98ad048a25fb9d49aef1 (diff) | |
download | bitflags-upstream-master.tar.gz |
Merge pull request #207 from niklasf/unsafe-from-bits-uncheckedupstream-master
Document from_bits_unchecked unsafety (#200)
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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 } |