Skip to content

Commit

Permalink
doc: reduce the scope of unsafe in the from_bits_unchecked example
Browse files Browse the repository at this point in the history
  • Loading branch information
meithecatte committed Feb 5, 2024
1 parent 76f8b87 commit 468b45e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,13 @@ pub trait BitFlag: Copy + Clone + 'static + _internal::RawBitFlags {
///
/// use enumflags2::BitFlag;
///
/// unsafe {
/// let from_bits = MyFlag::from_bits_unchecked(0b011);
/// assert_eq!(from_bits.contains(MyFlag::One), true);
/// assert_eq!(from_bits.contains(MyFlag::Two), true);
/// assert_eq!(from_bits.contains(MyFlag::Three), false);
/// }
/// let from_bits = unsafe {
/// MyFlag::from_bits_unchecked(0b011)
/// };
///
/// assert_eq!(from_bits.contains(MyFlag::One), true);
/// assert_eq!(from_bits.contains(MyFlag::Two), true);
/// assert_eq!(from_bits.contains(MyFlag::Three), false);
/// ```
///
/// # Safety
Expand Down

0 comments on commit 468b45e

Please sign in to comment.