You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Returns the number of leading zeros in the binary representation of `self`.
131
+
///
132
+
/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided.
133
+
///
134
+
/// # Examples
135
+
///
136
+
/// Basic usage:
137
+
///
138
+
/// ```
139
+
#[doc = concat!("let n = std::num::", stringify!($Ty),"::new(", stringify!($leading_zeros_test),").unwrap();")]
140
+
///
141
+
/// assert_eq!(n.leading_zeros(), 0);
142
+
/// ```
143
+
#[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
144
+
#[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
145
+
#[must_use = "this returns the result of the operation, \
146
+
without modifying the original"]
147
+
#[inline]
148
+
pubconstfn leading_zeros(self) -> u32{
149
+
// SAFETY: since `self` cannot be zero, it is safe to call `ctlz_nonzero`.
/// Returns the number of trailing zeros in the binary representation
154
+
/// of `self`.
155
+
///
156
+
/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided.
157
+
///
158
+
/// # Examples
159
+
///
160
+
/// Basic usage:
161
+
///
162
+
/// ```
163
+
#[doc = concat!("let n = std::num::", stringify!($Ty),"::new(0b0101000).unwrap();")]
164
+
///
165
+
/// assert_eq!(n.trailing_zeros(), 3);
166
+
/// ```
167
+
#[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
168
+
#[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
169
+
#[must_use = "this returns the result of the operation, \
170
+
without modifying the original"]
171
+
#[inline]
172
+
pubconstfn trailing_zeros(self) -> u32{
173
+
// SAFETY: since `self` cannot be zero, it is safe to call `cttz_nonzero`.
/// Returns the number of leading zeros in the binary representation of `self`.
214
-
///
215
-
/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided.
216
-
///
217
-
/// # Examples
218
-
///
219
-
/// Basic usage:
220
-
///
221
-
/// ```
222
-
#[doc = concat!("let n = std::num::", stringify!($Ty),"::new(", stringify!($LeadingTestExpr),").unwrap();")]
223
-
///
224
-
/// assert_eq!(n.leading_zeros(), 0);
225
-
/// ```
226
-
#[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
227
-
#[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
228
-
#[must_use = "this returns the result of the operation, \
229
-
without modifying the original"]
230
-
#[inline]
231
-
pubconstfn leading_zeros(self) -> u32{
232
-
// SAFETY: since `self` cannot be zero, it is safe to call `ctlz_nonzero`.
/// Returns the number of trailing zeros in the binary representation
237
-
/// of `self`.
238
-
///
239
-
/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided.
240
-
///
241
-
/// # Examples
242
-
///
243
-
/// Basic usage:
244
-
///
245
-
/// ```
246
-
#[doc = concat!("let n = std::num::", stringify!($Ty),"::new(0b0101000).unwrap();")]
247
-
///
248
-
/// assert_eq!(n.trailing_zeros(), 3);
249
-
/// ```
250
-
#[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
251
-
#[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
252
-
#[must_use = "this returns the result of the operation, \
253
-
without modifying the original"]
254
-
#[inline]
255
-
pubconstfn trailing_zeros(self) -> u32{
256
-
// SAFETY: since `self` cannot be zero, it is safe to call `cttz_nonzero`.
0 commit comments