We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e18cd56 commit 9bd198fCopy full SHA for 9bd198f
src/lib.rs
@@ -75,7 +75,8 @@ pub use num_traits::{One, Zero};
75
/// assert_eq!(log2(1 << 15), 15);
76
/// assert_eq!(log2(2usize.pow(18)), 18);
77
/// ```
78
-pub fn log2(x: usize) -> u32 {
+#[inline(always)]
79
+pub const fn log2(x: usize) -> u32 {
80
if x == 0 {
81
0
82
} else if x.is_power_of_two() {
0 commit comments