File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -558,7 +558,7 @@ pub struct BitFlags<T, N = <T as _internal::RawBitFlags>::Numeric> {
558
558
/// assert_eq!(x, Test::A | Test::C);
559
559
///
560
560
/// // Also works in const contexts:
561
- /// const X: BitFlags<Test> = make_bitflags!(Test::{A | C} );
561
+ /// const X: BitFlags<Test> = make_bitflags!(Test::A );
562
562
/// ```
563
563
#[ macro_export]
564
564
macro_rules! make_bitflags {
@@ -576,7 +576,17 @@ macro_rules! make_bitflags {
576
576
unsafe { $crate:: BitFlags :: <$enum>:: from_bits_unchecked_c(
577
577
n, $crate:: BitFlags :: CONST_TOKEN ) }
578
578
}
579
- }
579
+ } ;
580
+ ( $enum: ident :: $variant: ident ) => {
581
+ {
582
+ let flag: $enum = $enum:: $variant;
583
+ let n = flag as <$enum as $crate:: _internal:: RawBitFlags >:: Numeric ;
584
+ // SAFETY: The value has been created from the numeric value of
585
+ // the underlying enum, so only valid bits are set.
586
+ unsafe { $crate:: BitFlags :: <$enum>:: from_bits_unchecked_c(
587
+ n, $crate:: BitFlags :: CONST_TOKEN ) }
588
+ }
589
+ } ;
580
590
}
581
591
582
592
/// The default value returned is one with all flags unset, i. e. [`empty`][Self::empty],
You can’t perform that action at this time.
0 commit comments