@@ -149,7 +149,7 @@ macro_rules! int_impl {
149
149
/// Basic usage:
150
150
///
151
151
/// ```
152
- /// assert_eq!(u32 ::from_str_radix("A", 16), Ok(10));
152
+ /// assert_eq!(i32 ::from_str_radix("A", 16), Ok(10));
153
153
/// ```
154
154
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
155
155
pub fn from_str_radix( src: & str , radix: u32 ) -> Result <Self , ParseIntError > {
@@ -163,9 +163,9 @@ macro_rules! int_impl {
163
163
/// Basic usage:
164
164
///
165
165
/// ```
166
- /// let n = 0b01001100u8 ;
166
+ /// let n = -0b1000_0000i8 ;
167
167
///
168
- /// assert_eq!(n.count_ones(), 3 );
168
+ /// assert_eq!(n.count_ones(), 1 );
169
169
/// ```
170
170
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
171
171
#[ inline]
@@ -178,9 +178,9 @@ macro_rules! int_impl {
178
178
/// Basic usage:
179
179
///
180
180
/// ```
181
- /// let n = 0b01001100u8 ;
181
+ /// let n = -0b1000_0000i8 ;
182
182
///
183
- /// assert_eq!(n.count_zeros(), 5 );
183
+ /// assert_eq!(n.count_zeros(), 7 );
184
184
/// ```
185
185
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
186
186
#[ inline]
@@ -196,9 +196,9 @@ macro_rules! int_impl {
196
196
/// Basic usage:
197
197
///
198
198
/// ```
199
- /// let n = 0b0101000u16 ;
199
+ /// let n = -1i16 ;
200
200
///
201
- /// assert_eq!(n.leading_zeros(), 10 );
201
+ /// assert_eq!(n.leading_zeros(), 0 );
202
202
/// ```
203
203
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
204
204
#[ inline]
@@ -214,9 +214,9 @@ macro_rules! int_impl {
214
214
/// Basic usage:
215
215
///
216
216
/// ```
217
- /// let n = 0b0101000u16 ;
217
+ /// let n = -4i8 ;
218
218
///
219
- /// assert_eq!(n.trailing_zeros(), 3 );
219
+ /// assert_eq!(n.trailing_zeros(), 2 );
220
220
/// ```
221
221
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
222
222
#[ inline]
@@ -232,10 +232,10 @@ macro_rules! int_impl {
232
232
/// Basic usage:
233
233
///
234
234
/// ```
235
- /// let n = 0x0123456789ABCDEFu64 ;
236
- /// let m = 0x3456789ABCDEF012u64 ;
235
+ /// let n = 0x0123456789ABCDEFi64 ;
236
+ /// let m = -0x76543210FEDCBA99i64 ;
237
237
///
238
- /// assert_eq!(n.rotate_left(12 ), m);
238
+ /// assert_eq!(n.rotate_left(32 ), m);
239
239
/// ```
240
240
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
241
241
#[ inline]
@@ -252,10 +252,10 @@ macro_rules! int_impl {
252
252
/// Basic usage:
253
253
///
254
254
/// ```
255
- /// let n = 0x0123456789ABCDEFu64 ;
256
- /// let m = 0xDEF0123456789ABCu64 ;
255
+ /// let n = 0x0123456789ABCDEFi64 ;
256
+ /// let m = -0xFEDCBA987654322i64 ;
257
257
///
258
- /// assert_eq!(n.rotate_right(12 ), m);
258
+ /// assert_eq!(n.rotate_right(4 ), m);
259
259
/// ```
260
260
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
261
261
#[ inline]
@@ -270,8 +270,8 @@ macro_rules! int_impl {
270
270
/// Basic usage:
271
271
///
272
272
/// ```
273
- /// let n = 0x0123456789ABCDEFu64 ;
274
- /// let m = 0xEFCDAB8967452301u64 ;
273
+ /// let n = 0x0123456789ABCDEFi64 ;
274
+ /// let m = -0x1032547698BADCFFi64 ;
275
275
///
276
276
/// assert_eq!(n.swap_bytes(), m);
277
277
/// ```
@@ -291,12 +291,12 @@ macro_rules! int_impl {
291
291
/// Basic usage:
292
292
///
293
293
/// ```
294
- /// let n = 0x0123456789ABCDEFu64 ;
294
+ /// let n = 0x0123456789ABCDEFi64 ;
295
295
///
296
296
/// if cfg!(target_endian = "big") {
297
- /// assert_eq!(u64 ::from_be(n), n)
297
+ /// assert_eq!(i64 ::from_be(n), n)
298
298
/// } else {
299
- /// assert_eq!(u64 ::from_be(n), n.swap_bytes())
299
+ /// assert_eq!(i64 ::from_be(n), n.swap_bytes())
300
300
/// }
301
301
/// ```
302
302
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -315,12 +315,12 @@ macro_rules! int_impl {
315
315
/// Basic usage:
316
316
///
317
317
/// ```
318
- /// let n = 0x0123456789ABCDEFu64 ;
318
+ /// let n = 0x0123456789ABCDEFi64 ;
319
319
///
320
320
/// if cfg!(target_endian = "little") {
321
- /// assert_eq!(u64 ::from_le(n), n)
321
+ /// assert_eq!(i64 ::from_le(n), n)
322
322
/// } else {
323
- /// assert_eq!(u64 ::from_le(n), n.swap_bytes())
323
+ /// assert_eq!(i64 ::from_le(n), n.swap_bytes())
324
324
/// }
325
325
/// ```
326
326
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -339,7 +339,7 @@ macro_rules! int_impl {
339
339
/// Basic usage:
340
340
///
341
341
/// ```
342
- /// let n = 0x0123456789ABCDEFu64 ;
342
+ /// let n = 0x0123456789ABCDEFi64 ;
343
343
///
344
344
/// if cfg!(target_endian = "big") {
345
345
/// assert_eq!(n.to_be(), n)
@@ -363,7 +363,7 @@ macro_rules! int_impl {
363
363
/// Basic usage:
364
364
///
365
365
/// ```
366
- /// let n = 0x0123456789ABCDEFu64 ;
366
+ /// let n = 0x0123456789ABCDEFi64 ;
367
367
///
368
368
/// if cfg!(target_endian = "little") {
369
369
/// assert_eq!(n.to_le(), n)
@@ -385,8 +385,8 @@ macro_rules! int_impl {
385
385
/// Basic usage:
386
386
///
387
387
/// ```
388
- /// assert_eq!(5u16 .checked_add(65530 ), Some(65535 ));
389
- /// assert_eq!(6u16 .checked_add(65530 ), None);
388
+ /// assert_eq!(7i16 .checked_add(32760 ), Some(32767 ));
389
+ /// assert_eq!(8i16 .checked_add(32760 ), None);
390
390
/// ```
391
391
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
392
392
#[ inline]
@@ -421,8 +421,8 @@ macro_rules! int_impl {
421
421
/// Basic usage:
422
422
///
423
423
/// ```
424
- /// assert_eq!(5u8 .checked_mul(51 ), Some(255 ));
425
- /// assert_eq!(5u8 .checked_mul(52 ), None);
424
+ /// assert_eq!(6i8 .checked_mul(21 ), Some(126 ));
425
+ /// assert_eq!(6i8 .checked_mul(22 ), None);
426
426
/// ```
427
427
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
428
428
#[ inline]
@@ -753,8 +753,8 @@ macro_rules! int_impl {
753
753
/// Basic usage:
754
754
///
755
755
/// ```
756
- /// assert_eq!(1u8 .wrapping_shl(7), 128);
757
- /// assert_eq!(1u8 .wrapping_shl(8), 1);
756
+ /// assert_eq!((-1i8) .wrapping_shl(7), - 128);
757
+ /// assert_eq!((-1i8) .wrapping_shl(8), - 1);
758
758
/// ```
759
759
#[ stable( feature = "num_wrapping" , since = "1.2.0" ) ]
760
760
#[ inline( always) ]
@@ -778,8 +778,8 @@ macro_rules! int_impl {
778
778
/// Basic usage:
779
779
///
780
780
/// ```
781
- /// assert_eq!(128u8 .wrapping_shr(7), 1);
782
- /// assert_eq!(128u8 .wrapping_shr(8), 128);
781
+ /// assert_eq!((-128i8) .wrapping_shr(7), - 1);
782
+ /// assert_eq!((-128i8) .wrapping_shr(8), - 128);
783
783
/// ```
784
784
#[ stable( feature = "num_wrapping" , since = "1.2.0" ) ]
785
785
#[ inline( always) ]
@@ -1193,15 +1193,13 @@ macro_rules! uint_impl {
1193
1193
///
1194
1194
/// Leading and trailing whitespace represent an error.
1195
1195
///
1196
- /// # Arguments
1197
- ///
1198
- /// * src - A string slice
1199
- /// * radix - The base to use. Must lie in the range [2 .. 36]
1196
+ /// # Examples
1200
1197
///
1201
- /// # Return value
1198
+ /// Basic usage:
1202
1199
///
1203
- /// `Err(ParseIntError)` if the string did not represent a valid number.
1204
- /// Otherwise, `Ok(n)` where `n` is the integer represented by `src`.
1200
+ /// ```
1201
+ /// assert_eq!(u32::from_str_radix("A", 16), Ok(10));
1202
+ /// ```
1205
1203
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1206
1204
pub fn from_str_radix( src: & str , radix: u32 ) -> Result <Self , ParseIntError > {
1207
1205
from_str_radix( src, radix)
@@ -1745,7 +1743,7 @@ macro_rules! uint_impl {
1745
1743
/// Basic usage:
1746
1744
///
1747
1745
/// ```
1748
- /// assert_eq!(100i8 .wrapping_rem(10), 0);
1746
+ /// assert_eq!(100u8 .wrapping_rem(10), 0);
1749
1747
/// ```
1750
1748
#[ stable( feature = "num_wrapping" , since = "1.2.0" ) ]
1751
1749
#[ inline( always) ]
@@ -1783,6 +1781,13 @@ macro_rules! uint_impl {
1783
1781
/// where `mask` removes any high-order bits of `rhs` that
1784
1782
/// would cause the shift to exceed the bitwidth of the type.
1785
1783
///
1784
+ /// Note that this is *not* the same as a rotate-left; the
1785
+ /// RHS of a wrapping shift-left is restricted to the range
1786
+ /// of the type, rather than the bits shifted out of the LHS
1787
+ /// being returned to the other end. The primitive integer
1788
+ /// types all implement a `rotate_left` function, which may
1789
+ /// be what you want instead.
1790
+ ///
1786
1791
/// # Examples
1787
1792
///
1788
1793
/// Basic usage:
@@ -1801,6 +1806,13 @@ macro_rules! uint_impl {
1801
1806
/// where `mask` removes any high-order bits of `rhs` that
1802
1807
/// would cause the shift to exceed the bitwidth of the type.
1803
1808
///
1809
+ /// Note that this is *not* the same as a rotate-right; the
1810
+ /// RHS of a wrapping shift-right is restricted to the range
1811
+ /// of the type, rather than the bits shifted out of the LHS
1812
+ /// being returned to the other end. The primitive integer
1813
+ /// types all implement a `rotate_right` function, which may
1814
+ /// be what you want instead.
1815
+ ///
1804
1816
/// # Examples
1805
1817
///
1806
1818
/// Basic usage:
0 commit comments