Skip to content

Commit cd4b3ac

Browse files
Rollup merge of #104263 - albertlarsan68:add-ilog2-to-leading-zeroes-docs, r=scottmcm
Add a reference to ilog2 in leading_zeros integer docs Fixes #104248
2 parents fe80364 + a1909b7 commit cd4b3ac

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

library/core/src/num/int_macros.rs

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ macro_rules! int_impl {
107107

108108
/// Returns the number of leading zeros in the binary representation of `self`.
109109
///
110+
/// Depending on what you're doing with the value, you might also be interested in the
111+
/// [`ilog2`] function which returns a consistent number, even if the type widens.
112+
///
110113
/// # Examples
111114
///
112115
/// Basic usage:
@@ -116,6 +119,7 @@ macro_rules! int_impl {
116119
///
117120
/// assert_eq!(n.leading_zeros(), 0);
118121
/// ```
122+
#[doc = concat!("[`ilog2`]: ", stringify!($SelfT), "::ilog2")]
119123
#[stable(feature = "rust1", since = "1.0.0")]
120124
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
121125
#[must_use = "this returns the result of the operation, \

library/core/src/num/uint_macros.rs

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ macro_rules! uint_impl {
109109

110110
/// Returns the number of leading zeros in the binary representation of `self`.
111111
///
112+
/// Depending on what you're doing with the value, you might also be interested in the
113+
/// [`ilog2`] function which returns a consistent number, even if the type widens.
114+
///
112115
/// # Examples
113116
///
114117
/// Basic usage:
@@ -118,6 +121,7 @@ macro_rules! uint_impl {
118121
///
119122
/// assert_eq!(n.leading_zeros(), 2);
120123
/// ```
124+
#[doc = concat!("[`ilog2`]: ", stringify!($SelfT), "::ilog2")]
121125
#[stable(feature = "rust1", since = "1.0.0")]
122126
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
123127
#[must_use = "this returns the result of the operation, \

0 commit comments

Comments
 (0)