From c3fb4e64a8d0f2d41433ff7d7bb244ff39a650f4 Mon Sep 17 00:00:00 2001 From: Benjamin Prosnitz Date: Mon, 19 Oct 2020 16:58:51 -0500 Subject: [PATCH] Make from_bits a const fn 'if' now works in 'const fn as of rust 1.4.6 (https://blog.rust-lang.org/2020/08/27/Rust-1.46.0.html). I would love to have 'from_bits' be a 'const fn' because it is the safest from_* function. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 55daa5ea..d368f9a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -617,7 +617,7 @@ macro_rules! __impl_bitflags { /// Convert from underlying bit representation, unless that /// representation contains bits that do not correspond to a flag. #[inline] - pub fn from_bits(bits: $T) -> $crate::_core::option::Option<$BitFlags> { + pub const fn from_bits(bits: $T) -> $crate::_core::option::Option<$BitFlags> { if (bits & !$BitFlags::all().bits()) == 0 { $crate::_core::option::Option::Some($BitFlags { bits }) } else {