@@ -255,6 +255,9 @@ $EndFeature, "
255
255
///
256
256
/// # Examples
257
257
///
258
+ /// Please note that this example is shared between integer types.
259
+ /// Which explains why `i64` is used here.
260
+ ///
258
261
/// Basic usage:
259
262
///
260
263
/// ```
@@ -277,6 +280,9 @@ $EndFeature, "
277
280
///
278
281
/// # Examples
279
282
///
283
+ /// Please note that this example is shared between integer types.
284
+ /// Which explains why `i64` is used here.
285
+ ///
280
286
/// Basic usage:
281
287
///
282
288
/// ```
@@ -295,6 +301,9 @@ $EndFeature, "
295
301
///
296
302
/// # Examples
297
303
///
304
+ /// Please note that this example is shared between integer types.
305
+ /// Which explains why `i16` is used here.
306
+ ///
298
307
/// Basic usage:
299
308
///
300
309
/// ```
@@ -1477,22 +1486,23 @@ Basic usage:
1477
1486
}
1478
1487
}
1479
1488
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
+ }
1496
1506
}
1497
1507
1498
1508
doc_comment! {
@@ -1537,6 +1547,9 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
1537
1547
///
1538
1548
/// Basic usage:
1539
1549
///
1550
+ /// Please note that this example is shared between integer types.
1551
+ /// Which explains why `u64` is used here.
1552
+ ///
1540
1553
/// ```
1541
1554
/// let n = 0x0123456789ABCDEFu64;
1542
1555
/// let m = 0x3456789ABCDEF012u64;
@@ -1561,6 +1574,9 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
1561
1574
///
1562
1575
/// Basic usage:
1563
1576
///
1577
+ /// Please note that this example is shared between integer types.
1578
+ /// Which explains why `u64` is used here.
1579
+ ///
1564
1580
/// ```
1565
1581
/// let n = 0x0123456789ABCDEFu64;
1566
1582
/// let m = 0xDEF0123456789ABCu64;
@@ -1581,6 +1597,9 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, "
1581
1597
///
1582
1598
/// Basic usage:
1583
1599
///
1600
+ /// Please note that this example is shared between integer types.
1601
+ /// Which explains why `u16` is used here.
1602
+ ///
1584
1603
/// ```
1585
1604
/// let n: u16 = 0b0000000_01010101;
1586
1605
/// assert_eq!(n, 85);
@@ -1985,6 +2004,9 @@ $EndFeature, "
1985
2004
///
1986
2005
/// Basic usage:
1987
2006
///
2007
+ /// Please note that this example is shared between integer types.
2008
+ /// Which explains why `u8` is used here.
2009
+ ///
1988
2010
/// ```
1989
2011
/// assert_eq!(10u8.wrapping_mul(12), 120);
1990
2012
/// assert_eq!(25u8.wrapping_mul(12), 44);
@@ -2054,6 +2076,9 @@ Basic usage:
2054
2076
///
2055
2077
/// Basic usage:
2056
2078
///
2079
+ /// Please note that this example is shared between integer types.
2080
+ /// Which explains why `i8` is used here.
2081
+ ///
2057
2082
/// ```
2058
2083
/// assert_eq!(100i8.wrapping_neg(), -100);
2059
2084
/// assert_eq!((-128i8).wrapping_neg(), -128);
@@ -2187,7 +2212,10 @@ $EndFeature, "
2187
2212
///
2188
2213
/// # Examples
2189
2214
///
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.
2191
2219
///
2192
2220
/// ```
2193
2221
/// assert_eq!(5u32.overflowing_mul(2), (10, false));
0 commit comments