@@ -149,7 +149,7 @@ macro_rules! int_impl {
149149 /// Basic usage:
150150 ///
151151 /// ```
152- /// assert_eq!(u32 ::from_str_radix("A", 16), Ok(10));
152+ /// assert_eq!(i32 ::from_str_radix("A", 16), Ok(10));
153153 /// ```
154154 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
155155 pub fn from_str_radix( src: & str , radix: u32 ) -> Result <Self , ParseIntError > {
@@ -163,9 +163,9 @@ macro_rules! int_impl {
163163 /// Basic usage:
164164 ///
165165 /// ```
166- /// let n = 0b01001100u8 ;
166+ /// let n = -0b1000_0000i8 ;
167167 ///
168- /// assert_eq!(n.count_ones(), 3 );
168+ /// assert_eq!(n.count_ones(), 1 );
169169 /// ```
170170 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
171171 #[ inline]
@@ -178,9 +178,9 @@ macro_rules! int_impl {
178178 /// Basic usage:
179179 ///
180180 /// ```
181- /// let n = 0b01001100u8 ;
181+ /// let n = -0b1000_0000i8 ;
182182 ///
183- /// assert_eq!(n.count_zeros(), 5 );
183+ /// assert_eq!(n.count_zeros(), 7 );
184184 /// ```
185185 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
186186 #[ inline]
@@ -196,9 +196,9 @@ macro_rules! int_impl {
196196 /// Basic usage:
197197 ///
198198 /// ```
199- /// let n = 0b0101000u16 ;
199+ /// let n = -1i16 ;
200200 ///
201- /// assert_eq!(n.leading_zeros(), 10 );
201+ /// assert_eq!(n.leading_zeros(), 0 );
202202 /// ```
203203 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
204204 #[ inline]
@@ -214,9 +214,9 @@ macro_rules! int_impl {
214214 /// Basic usage:
215215 ///
216216 /// ```
217- /// let n = 0b0101000u16 ;
217+ /// let n = -4i8 ;
218218 ///
219- /// assert_eq!(n.trailing_zeros(), 3 );
219+ /// assert_eq!(n.trailing_zeros(), 2 );
220220 /// ```
221221 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
222222 #[ inline]
@@ -232,10 +232,10 @@ macro_rules! int_impl {
232232 /// Basic usage:
233233 ///
234234 /// ```
235- /// let n = 0x0123456789ABCDEFu64 ;
236- /// let m = 0x3456789ABCDEF012u64 ;
235+ /// let n = 0x0123456789ABCDEFi64 ;
236+ /// let m = -0x76543210FEDCBA99i64 ;
237237 ///
238- /// assert_eq!(n.rotate_left(12 ), m);
238+ /// assert_eq!(n.rotate_left(32 ), m);
239239 /// ```
240240 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
241241 #[ inline]
@@ -252,10 +252,10 @@ macro_rules! int_impl {
252252 /// Basic usage:
253253 ///
254254 /// ```
255- /// let n = 0x0123456789ABCDEFu64 ;
256- /// let m = 0xDEF0123456789ABCu64 ;
255+ /// let n = 0x0123456789ABCDEFi64 ;
256+ /// let m = -0xFEDCBA987654322i64 ;
257257 ///
258- /// assert_eq!(n.rotate_right(12 ), m);
258+ /// assert_eq!(n.rotate_right(4 ), m);
259259 /// ```
260260 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
261261 #[ inline]
@@ -270,8 +270,8 @@ macro_rules! int_impl {
270270 /// Basic usage:
271271 ///
272272 /// ```
273- /// let n = 0x0123456789ABCDEFu64 ;
274- /// let m = 0xEFCDAB8967452301u64 ;
273+ /// let n = 0x0123456789ABCDEFi64 ;
274+ /// let m = -0x1032547698BADCFFi64 ;
275275 ///
276276 /// assert_eq!(n.swap_bytes(), m);
277277 /// ```
@@ -291,12 +291,12 @@ macro_rules! int_impl {
291291 /// Basic usage:
292292 ///
293293 /// ```
294- /// let n = 0x0123456789ABCDEFu64 ;
294+ /// let n = 0x0123456789ABCDEFi64 ;
295295 ///
296296 /// if cfg!(target_endian = "big") {
297- /// assert_eq!(u64 ::from_be(n), n)
297+ /// assert_eq!(i64 ::from_be(n), n)
298298 /// } else {
299- /// assert_eq!(u64 ::from_be(n), n.swap_bytes())
299+ /// assert_eq!(i64 ::from_be(n), n.swap_bytes())
300300 /// }
301301 /// ```
302302 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -315,12 +315,12 @@ macro_rules! int_impl {
315315 /// Basic usage:
316316 ///
317317 /// ```
318- /// let n = 0x0123456789ABCDEFu64 ;
318+ /// let n = 0x0123456789ABCDEFi64 ;
319319 ///
320320 /// if cfg!(target_endian = "little") {
321- /// assert_eq!(u64 ::from_le(n), n)
321+ /// assert_eq!(i64 ::from_le(n), n)
322322 /// } else {
323- /// assert_eq!(u64 ::from_le(n), n.swap_bytes())
323+ /// assert_eq!(i64 ::from_le(n), n.swap_bytes())
324324 /// }
325325 /// ```
326326 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -339,7 +339,7 @@ macro_rules! int_impl {
339339 /// Basic usage:
340340 ///
341341 /// ```
342- /// let n = 0x0123456789ABCDEFu64 ;
342+ /// let n = 0x0123456789ABCDEFi64 ;
343343 ///
344344 /// if cfg!(target_endian = "big") {
345345 /// assert_eq!(n.to_be(), n)
@@ -363,7 +363,7 @@ macro_rules! int_impl {
363363 /// Basic usage:
364364 ///
365365 /// ```
366- /// let n = 0x0123456789ABCDEFu64 ;
366+ /// let n = 0x0123456789ABCDEFi64 ;
367367 ///
368368 /// if cfg!(target_endian = "little") {
369369 /// assert_eq!(n.to_le(), n)
@@ -385,8 +385,8 @@ macro_rules! int_impl {
385385 /// Basic usage:
386386 ///
387387 /// ```
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);
390390 /// ```
391391 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
392392 #[ inline]
@@ -421,8 +421,8 @@ macro_rules! int_impl {
421421 /// Basic usage:
422422 ///
423423 /// ```
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);
426426 /// ```
427427 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
428428 #[ inline]
@@ -753,8 +753,8 @@ macro_rules! int_impl {
753753 /// Basic usage:
754754 ///
755755 /// ```
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);
758758 /// ```
759759 #[ stable( feature = "num_wrapping" , since = "1.2.0" ) ]
760760 #[ inline( always) ]
@@ -778,8 +778,8 @@ macro_rules! int_impl {
778778 /// Basic usage:
779779 ///
780780 /// ```
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);
783783 /// ```
784784 #[ stable( feature = "num_wrapping" , since = "1.2.0" ) ]
785785 #[ inline( always) ]
@@ -1193,15 +1193,13 @@ macro_rules! uint_impl {
11931193 ///
11941194 /// Leading and trailing whitespace represent an error.
11951195 ///
1196- /// # Arguments
1197- ///
1198- /// * src - A string slice
1199- /// * radix - The base to use. Must lie in the range [2 .. 36]
1196+ /// # Examples
12001197 ///
1201- /// # Return value
1198+ /// Basic usage:
12021199 ///
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+ /// ```
12051203 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
12061204 pub fn from_str_radix( src: & str , radix: u32 ) -> Result <Self , ParseIntError > {
12071205 from_str_radix( src, radix)
@@ -1745,7 +1743,7 @@ macro_rules! uint_impl {
17451743 /// Basic usage:
17461744 ///
17471745 /// ```
1748- /// assert_eq!(100i8 .wrapping_rem(10), 0);
1746+ /// assert_eq!(100u8 .wrapping_rem(10), 0);
17491747 /// ```
17501748 #[ stable( feature = "num_wrapping" , since = "1.2.0" ) ]
17511749 #[ inline( always) ]
@@ -1783,6 +1781,13 @@ macro_rules! uint_impl {
17831781 /// where `mask` removes any high-order bits of `rhs` that
17841782 /// would cause the shift to exceed the bitwidth of the type.
17851783 ///
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+ ///
17861791 /// # Examples
17871792 ///
17881793 /// Basic usage:
@@ -1801,6 +1806,13 @@ macro_rules! uint_impl {
18011806 /// where `mask` removes any high-order bits of `rhs` that
18021807 /// would cause the shift to exceed the bitwidth of the type.
18031808 ///
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+ ///
18041816 /// # Examples
18051817 ///
18061818 /// Basic usage:
0 commit comments