Skip to content

Commit d692e94

Browse files
Notify users that this example is shared through integer types
1 parent 9a30673 commit d692e94

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

src/libcore/num/mod.rs

+45-17
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ $EndFeature, "
255255
///
256256
/// # Examples
257257
///
258+
/// Please note that this example is shared between integer types.
259+
/// Which explains why `i64` is used here.
260+
///
258261
/// Basic usage:
259262
///
260263
/// ```
@@ -277,6 +280,9 @@ $EndFeature, "
277280
///
278281
/// # Examples
279282
///
283+
/// Please note that this example is shared between integer types.
284+
/// Which explains why `i64` is used here.
285+
///
280286
/// Basic usage:
281287
///
282288
/// ```
@@ -295,6 +301,9 @@ $EndFeature, "
295301
///
296302
/// # Examples
297303
///
304+
/// Please note that this example is shared between integer types.
305+
/// Which explains why `i16` is used here.
306+
///
298307
/// Basic usage:
299308
///
300309
/// ```
@@ -1477,22 +1486,23 @@ Basic usage:
14771486
}
14781487
}
14791488

1480-
/// Returns the number of leading zeros in the binary representation
1481-
/// of `self`.
1482-
///
1483-
/// # Examples
1484-
///
1485-
/// Basic usage:
1486-
///
1487-
/// ```
1488-
/// let n = 0b0101000u16;
1489-
///
1490-
/// assert_eq!(n.leading_zeros(), 10);
1491-
/// ```
1492-
#[stable(feature = "rust1", since = "1.0.0")]
1493-
#[inline]
1494-
pub fn leading_zeros(self) -> u32 {
1495-
unsafe { intrinsics::ctlz(self as $ActualT) as u32 }
1489+
doc_comment! {
1490+
concat!("Returns the number of leading zeros in the binary representation of `self`.
1491+
1492+
# Examples
1493+
1494+
Basic usage:
1495+
1496+
```
1497+
", $Feature, "let n = ", stringify!($SelfT), "::max_value() >> 2;
1498+
1499+
assert_eq!(n.leading_zeros(), 2);", $EndFeature, "
1500+
```"),
1501+
#[stable(feature = "rust1", since = "1.0.0")]
1502+
#[inline]
1503+
pub fn leading_zeros(self) -> u32 {
1504+
unsafe { intrinsics::ctlz(self as $ActualT) as u32 }
1505+
}
14961506
}
14971507

14981508
doc_comment! {
@@ -1537,6 +1547,9 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
15371547
///
15381548
/// Basic usage:
15391549
///
1550+
/// Please note that this example is shared between integer types.
1551+
/// Which explains why `u64` is used here.
1552+
///
15401553
/// ```
15411554
/// let n = 0x0123456789ABCDEFu64;
15421555
/// let m = 0x3456789ABCDEF012u64;
@@ -1561,6 +1574,9 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
15611574
///
15621575
/// Basic usage:
15631576
///
1577+
/// Please note that this example is shared between integer types.
1578+
/// Which explains why `u64` is used here.
1579+
///
15641580
/// ```
15651581
/// let n = 0x0123456789ABCDEFu64;
15661582
/// let m = 0xDEF0123456789ABCu64;
@@ -1581,6 +1597,9 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
15811597
///
15821598
/// Basic usage:
15831599
///
1600+
/// Please note that this example is shared between integer types.
1601+
/// Which explains why `u16` is used here.
1602+
///
15841603
/// ```
15851604
/// let n: u16 = 0b0000000_01010101;
15861605
/// assert_eq!(n, 85);
@@ -1985,6 +2004,9 @@ $EndFeature, "
19852004
///
19862005
/// Basic usage:
19872006
///
2007+
/// Please note that this example is shared between integer types.
2008+
/// Which explains why `u8` is used here.
2009+
///
19882010
/// ```
19892011
/// assert_eq!(10u8.wrapping_mul(12), 120);
19902012
/// assert_eq!(25u8.wrapping_mul(12), 44);
@@ -2054,6 +2076,9 @@ Basic usage:
20542076
///
20552077
/// Basic usage:
20562078
///
2079+
/// Please note that this example is shared between integer types.
2080+
/// Which explains why `i8` is used here.
2081+
///
20572082
/// ```
20582083
/// assert_eq!(100i8.wrapping_neg(), -100);
20592084
/// assert_eq!((-128i8).wrapping_neg(), -128);
@@ -2187,7 +2212,10 @@ $EndFeature, "
21872212
///
21882213
/// # Examples
21892214
///
2190-
/// Basic usage
2215+
/// Basic usage:
2216+
///
2217+
/// Please note that this example is shared between integer types.
2218+
/// Which explains why `u32` is used here.
21912219
///
21922220
/// ```
21932221
/// assert_eq!(5u32.overflowing_mul(2), (10, false));

0 commit comments

Comments
 (0)