From f67e7470b31a38e80c9f1007e4182ff5b56db2f7 Mon Sep 17 00:00:00 2001 From: Alfie John Date: Thu, 22 Jan 2015 14:08:56 +0000 Subject: [PATCH] Moving away from deprecated i/u suffixes in libcore --- src/libcore/atomic.rs | 20 ++++++------- src/libcore/cell.rs | 8 +++--- src/libcore/char.rs | 16 +++++------ src/libcore/cmp.rs | 16 +++++------ src/libcore/default.rs | 20 ++++++------- src/libcore/fmt/float.rs | 6 ++-- src/libcore/fmt/mod.rs | 6 ++-- src/libcore/fmt/num.rs | 2 +- src/libcore/hash/sip.rs | 2 +- src/libcore/iter.rs | 10 +++---- src/libcore/macros.rs | 10 +++---- src/libcore/mem.rs | 14 ++++----- src/libcore/num/f32.rs | 6 ++-- src/libcore/num/f64.rs | 6 ++-- src/libcore/num/mod.rs | 8 +++--- src/libcore/option.rs | 62 ++++++++++++++++++++-------------------- src/libcore/result.rs | 26 ++++++++--------- src/libcore/slice.rs | 8 +++--- src/libcore/str/mod.rs | 10 +++---- 19 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs index 18f7fff9053..e75481198d4 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -589,7 +589,7 @@ impl AtomicUsize { /// ``` /// use std::sync::atomic::AtomicUsize; /// - /// let atomic_forty_two = AtomicUsize::new(42u); + /// let atomic_forty_two = AtomicUsize::new(42); /// ``` #[inline] pub fn new(v: usize) -> AtomicUsize { @@ -765,7 +765,7 @@ impl AtomicPtr { /// ``` /// use std::sync::atomic::AtomicPtr; /// - /// let ptr = &mut 5i; + /// let ptr = &mut 5; /// let atomic_ptr = AtomicPtr::new(ptr); /// ``` #[inline] @@ -787,7 +787,7 @@ impl AtomicPtr { /// ``` /// use std::sync::atomic::{AtomicPtr, Ordering}; /// - /// let ptr = &mut 5i; + /// let ptr = &mut 5; /// let some_ptr = AtomicPtr::new(ptr); /// /// let value = some_ptr.load(Ordering::Relaxed); @@ -809,10 +809,10 @@ impl AtomicPtr { /// ``` /// use std::sync::atomic::{AtomicPtr, Ordering}; /// - /// let ptr = &mut 5i; + /// let ptr = &mut 5; /// let some_ptr = AtomicPtr::new(ptr); /// - /// let other_ptr = &mut 10i; + /// let other_ptr = &mut 10; /// /// some_ptr.store(other_ptr, Ordering::Relaxed); /// ``` @@ -835,10 +835,10 @@ impl AtomicPtr { /// ``` /// use std::sync::atomic::{AtomicPtr, Ordering}; /// - /// let ptr = &mut 5i; + /// let ptr = &mut 5; /// let some_ptr = AtomicPtr::new(ptr); /// - /// let other_ptr = &mut 10i; + /// let other_ptr = &mut 10; /// /// let value = some_ptr.swap(other_ptr, Ordering::Relaxed); /// ``` @@ -860,11 +860,11 @@ impl AtomicPtr { /// ``` /// use std::sync::atomic::{AtomicPtr, Ordering}; /// - /// let ptr = &mut 5i; + /// let ptr = &mut 5; /// let some_ptr = AtomicPtr::new(ptr); /// - /// let other_ptr = &mut 10i; - /// let another_ptr = &mut 10i; + /// let other_ptr = &mut 10; + /// let another_ptr = &mut 10; /// /// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed); /// ``` diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 7f73be9eb5f..94307166ad5 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -67,10 +67,10 @@ //! //! fn main() { //! let shared_map: Rc> = Rc::new(RefCell::new(HashMap::new())); -//! shared_map.borrow_mut().insert("africa", 92388i); -//! shared_map.borrow_mut().insert("kyoto", 11837i); -//! shared_map.borrow_mut().insert("piccadilly", 11826i); -//! shared_map.borrow_mut().insert("marbles", 38i); +//! shared_map.borrow_mut().insert("africa", 92388); +//! shared_map.borrow_mut().insert("kyoto", 11837); +//! shared_map.borrow_mut().insert("piccadilly", 11826); +//! shared_map.borrow_mut().insert("marbles", 38); //! } //! ``` //! diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 0e6b634bd11..c17f7cdccba 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -102,7 +102,7 @@ pub fn from_digit(num: uint, radix: uint) -> Option { if num < 10 { Some(transmute(('0' as uint + num) as u32)) } else { - Some(transmute(('a' as uint + num - 10u) as u32)) + Some(transmute(('a' as uint + num - 10) as u32)) } } } else { @@ -208,8 +208,8 @@ impl CharExt for char { } let val = match self { '0' ... '9' => self as uint - ('0' as uint), - 'a' ... 'z' => self as uint + 10u - ('a' as uint), - 'A' ... 'Z' => self as uint + 10u - ('A' as uint), + 'a' ... 'z' => self as uint + 10 - ('a' as uint), + 'A' ... 'Z' => self as uint + 10 - ('A' as uint), _ => return None, }; if val < radix { Some(val) } @@ -241,10 +241,10 @@ impl CharExt for char { fn len_utf8(self) -> uint { let code = self as u32; match () { - _ if code < MAX_ONE_B => 1u, - _ if code < MAX_TWO_B => 2u, - _ if code < MAX_THREE_B => 3u, - _ => 4u, + _ if code < MAX_ONE_B => 1, + _ if code < MAX_TWO_B => 2, + _ if code < MAX_THREE_B => 3, + _ => 4, } } @@ -359,7 +359,7 @@ impl Iterator for EscapeUnicode { Some('u') } EscapeUnicodeState::LeftBrace => { - let mut n = 0u; + let mut n = 0; while (self.c as u32) >> (4 * (n + 1)) != 0 { n += 1; } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index c1f1997df74..6cda9d0e653 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -110,13 +110,13 @@ pub trait Eq: PartialEq { pub enum Ordering { /// An ordering where a compared value is less [than another]. #[stable] - Less = -1i, + Less = -1, /// An ordering where a compared value is equal [to another]. #[stable] - Equal = 0i, + Equal = 0, /// An ordering where a compared value is greater [than another]. #[stable] - Greater = 1i, + Greater = 1, } impl Ordering { @@ -132,12 +132,12 @@ impl Ordering { /// assert_eq!(Equal.reverse(), Equal); /// assert_eq!(Greater.reverse(), Less); /// - /// let mut data: &mut [_] = &mut [2u, 10, 5, 8]; + /// let mut data: &mut [_] = &mut [2, 10, 5, 8]; /// /// // sort the array from largest to smallest. /// data.sort_by(|a, b| a.cmp(b).reverse()); /// - /// let b: &mut [_] = &mut [10u, 8, 5, 2]; + /// let b: &mut [_] = &mut [10, 8, 5, 2]; /// assert!(data == b); /// ``` #[inline] @@ -174,9 +174,9 @@ pub trait Ord: Eq + PartialOrd { /// ``` /// use std::cmp::Ordering::{Less, Equal, Greater}; /// - /// assert_eq!( 5u.cmp(&10), Less); // because 5 < 10 - /// assert_eq!(10u.cmp(&5), Greater); // because 10 > 5 - /// assert_eq!( 5u.cmp(&5), Equal); // because 5 == 5 + /// assert_eq!( 5.cmp(&10), Less); // because 5 < 10 + /// assert_eq!(10.cmp(&5), Greater); // because 10 > 5 + /// assert_eq!( 5.cmp(&5), Equal); // because 5 == 5 /// ``` #[stable] fn cmp(&self, other: &Self) -> Ordering; diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 8d4ecf72243..3b1e5e23150 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -150,17 +150,17 @@ default_impl! { (), () } default_impl! { bool, false } default_impl! { char, '\x00' } -default_impl! { uint, 0u } -default_impl! { u8, 0u8 } -default_impl! { u16, 0u16 } -default_impl! { u32, 0u32 } -default_impl! { u64, 0u64 } +default_impl! { uint, 0 } +default_impl! { u8, 0 } +default_impl! { u16, 0 } +default_impl! { u32, 0 } +default_impl! { u64, 0 } -default_impl! { int, 0i } -default_impl! { i8, 0i8 } -default_impl! { i16, 0i16 } -default_impl! { i32, 0i32 } -default_impl! { i64, 0i64 } +default_impl! { int, 0 } +default_impl! { i8, 0 } +default_impl! { i16, 0 } +default_impl! { i32, 0 } +default_impl! { i64, 0 } default_impl! { f32, 0.0f32 } default_impl! { f64, 0.0f64 } diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 245dc00d838..50123499eba 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -53,7 +53,7 @@ pub enum SignFormat { SignNeg } -static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; +static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11; /// Converts a number to its string representation as a byte vector. /// This is meant to be a common base implementation for all numeric string @@ -191,7 +191,7 @@ pub fn float_to_str_bytes_common( if deccum != _0 || (limit_digits && exact && digit_count > 0) { buf[end] = b'.'; end += 1; - let mut dig = 0u; + let mut dig = 0; // calculate new digits while // - there is no limit and there are digits left @@ -218,7 +218,7 @@ pub fn float_to_str_bytes_common( // Decrease the deccumulator one fractional digit at a time deccum = deccum.fract(); - dig += 1u; + dig += 1; } // If digits are limited, and that limit has been reached, diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 0e8d31a62ee..17eff98d429 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -560,8 +560,8 @@ impl<'a> Formatter<'a> { }; let (pre_pad, post_pad) = match align { - rt::AlignLeft => (0u, padding), - rt::AlignRight | rt::AlignUnknown => (padding, 0u), + rt::AlignLeft => (0, padding), + rt::AlignRight | rt::AlignUnknown => (padding, 0), rt::AlignCenter => (padding / 2, (padding + 1) / 2), }; @@ -846,7 +846,7 @@ macro_rules! tuple { fn fmt(&self, f: &mut Formatter) -> Result { try!(write!(f, "(")); let ($(ref $name,)*) = *self; - let mut n = 0i; + let mut n = 0; $( if n > 0 { try!(write!(f, ", ")); diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index c456b3379e8..a659a9988bb 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -145,7 +145,7 @@ pub struct RadixFmt(T, R); /// /// ``` /// use std::fmt::radix; -/// assert_eq!(format!("{}", radix(55i, 36)), "1j".to_string()); +/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string()); /// ``` #[unstable = "may be renamed or move to a different module"] pub fn radix(x: T, base: u8) -> RadixFmt { diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index c20fb8457d2..8840eaf5fbc 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -122,7 +122,7 @@ impl Writer for SipHasher { let length = msg.len(); self.length += length; - let mut needed = 0u; + let mut needed = 0; if self.ntail != 0 { needed = 8 - self.ntail; diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2673cf1af78..591822d6e1b 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -33,7 +33,7 @@ //! translated to the `loop` below. //! //! ``` -//! let values = vec![1i, 2, 3]; +//! let values = vec![1, 2, 3]; //! //! // "Syntactical sugar" taking advantage of an iterator //! for &x in values.iter() { @@ -615,7 +615,7 @@ pub trait IteratorExt: Iterator + Sized { /// # Examples /// /// ``` - /// let a = [1i, 2, 3, 4, 5]; + /// let a = [1, 2, 3, 4, 5]; /// assert!(a.iter().all(|x| *x > 0)); /// assert!(!a.iter().all(|x| *x > 2)); /// ``` @@ -1141,7 +1141,7 @@ pub trait AdditiveIterator { /// ``` /// use std::iter::AdditiveIterator; /// - /// let a = [1i, 2, 3, 4, 5]; + /// let a = [1i32, 2, 3, 4, 5]; /// let mut it = a.iter().map(|&x| x); /// assert!(it.sum() == 15); /// ``` @@ -1183,7 +1183,7 @@ pub trait MultiplicativeIterator { /// use std::iter::{count, MultiplicativeIterator}; /// /// fn factorial(n: usize) -> usize { - /// count(1u, 1).take_while(|&i| i <= n).product() + /// count(1, 1).take_while(|&i| i <= n).product() /// } /// assert!(factorial(0) == 1); /// assert!(factorial(1) == 1); @@ -2526,7 +2526,7 @@ pub struct Range { /// ``` /// let array = [0, 1, 2, 3, 4]; /// -/// for i in range(0, 5u) { +/// for i in range(0, 5) { /// println!("{}", i); /// assert_eq!(i, array[i]); /// } diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 1c37126e8e9..d44eaae820f 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -48,7 +48,7 @@ macro_rules! panic { /// let x = true; /// assert!(x, "x wasn't true!"); /// -/// let a = 3i; let b = 27i; +/// let a = 3; let b = 27; /// assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] @@ -74,8 +74,8 @@ macro_rules! assert { /// # Example /// /// ``` -/// let a = 3i; -/// let b = 1i + 2i; +/// let a = 3; +/// let b = 1 + 2; /// assert_eq!(a, b); /// ``` #[macro_export] @@ -141,8 +141,8 @@ macro_rules! debug_assert { /// # Example /// /// ``` -/// let a = 3i; -/// let b = 1i + 2i; +/// let a = 3; +/// let b = 1 + 2; /// debug_assert_eq!(a, b); /// ``` #[macro_export] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 8438c9b206e..608a78325b3 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -187,13 +187,13 @@ pub unsafe fn uninitialized() -> T { /// ``` /// use std::mem; /// -/// let x = &mut 5i; -/// let y = &mut 42i; +/// let x = &mut 5; +/// let y = &mut 42; /// /// mem::swap(x, y); /// -/// assert_eq!(42i, *x); -/// assert_eq!(5i, *y); +/// assert_eq!(42, *x); +/// assert_eq!(5, *y); /// ``` #[inline] #[stable] @@ -277,7 +277,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// ``` /// use std::cell::RefCell; /// -/// let x = RefCell::new(1i); +/// let x = RefCell::new(1); /// /// let mut mutable_borrow = x.borrow_mut(); /// *mutable_borrow = 1; @@ -306,9 +306,9 @@ pub fn drop(_x: T) { } /// ``` /// use std::mem; /// -/// let one = unsafe { mem::transmute_copy(&1i) }; +/// let one = unsafe { mem::transmute_copy(&1) }; /// -/// assert_eq!(1u, one); +/// assert_eq!(1, one); /// ``` #[inline] #[stable] diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index f8a85e788e9..2186101bc2f 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -23,12 +23,12 @@ use num::FpCategory as Fp; use option::Option; #[unstable = "pending integer conventions"] -pub const RADIX: uint = 2u; +pub const RADIX: uint = 2; #[unstable = "pending integer conventions"] -pub const MANTISSA_DIGITS: uint = 24u; +pub const MANTISSA_DIGITS: uint = 24; #[unstable = "pending integer conventions"] -pub const DIGITS: uint = 6u; +pub const DIGITS: uint = 6; #[stable] pub const EPSILON: f32 = 1.19209290e-07_f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 840428179cd..a7f0266b095 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -27,11 +27,11 @@ use option::Option; // members of `Bounded` and `Float`. #[unstable = "pending integer conventions"] -pub const RADIX: uint = 2u; +pub const RADIX: uint = 2; -pub const MANTISSA_DIGITS: uint = 53u; +pub const MANTISSA_DIGITS: uint = 53; #[unstable = "pending integer conventions"] -pub const DIGITS: uint = 15u; +pub const DIGITS: uint = 15; #[stable] pub const EPSILON: f64 = 2.2204460492503131e-16_f64; diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 599a5515e3b..910c9e6c670 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -356,7 +356,7 @@ pub trait Int /// ```rust /// use std::num::Int; /// - /// assert_eq!(2i.pow(4), 16); + /// assert_eq!(2.pow(4), 16); /// ``` #[unstable = "pending integer conventions"] #[inline] @@ -1185,7 +1185,7 @@ impl_from_primitive! { f64, to_f64 } /// ``` /// use std::num; /// -/// let twenty: f32 = num::cast(0x14i).unwrap(); +/// let twenty: f32 = num::cast(0x14).unwrap(); /// assert_eq!(twenty, 20f32); /// ``` /// @@ -1571,8 +1571,8 @@ macro_rules! from_str_radix_float_impl { let exp = match exp_info { Some((c, offset)) => { let base = match c { - 'E' | 'e' if radix == 10 => 10u as $T, - 'P' | 'p' if radix == 16 => 2u as $T, + 'E' | 'e' if radix == 10 => 10.0, + 'P' | 'p' if radix == 16 => 2.0, _ => return None, }; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index af7fc875389..3ee2aa678e9 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -254,12 +254,12 @@ impl Option { /// # Example /// /// ``` - /// let mut x = Some(2u); + /// let mut x = Some(2); /// match x.as_mut() { /// Some(v) => *v = 42, /// None => {}, /// } - /// assert_eq!(x, Some(42u)); + /// assert_eq!(x, Some(42)); /// ``` #[inline] #[stable] @@ -384,9 +384,9 @@ impl Option { /// # Example /// /// ``` - /// let k = 10u; - /// assert_eq!(Some(4u).unwrap_or_else(|| 2 * k), 4u); - /// assert_eq!(None.unwrap_or_else(|| 2 * k), 20u); + /// let k = 10i32; + /// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4); + /// assert_eq!(None.unwrap_or_else(|| 2 * k), 20); /// ``` #[inline] #[stable] @@ -427,10 +427,10 @@ impl Option { /// /// ``` /// let x = Some("foo"); - /// assert_eq!(x.map_or(42u, |v| v.len()), 3u); + /// assert_eq!(x.map_or(42, |v| v.len()), 3); /// /// let x: Option<&str> = None; - /// assert_eq!(x.map_or(42u, |v| v.len()), 42u); + /// assert_eq!(x.map_or(42, |v| v.len()), 42); /// ``` #[inline] #[stable] @@ -446,13 +446,13 @@ impl Option { /// # Example /// /// ``` - /// let k = 21u; + /// let k = 21; /// /// let x = Some("foo"); - /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3u); + /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3); /// /// let x: Option<&str> = None; - /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42u); + /// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42); /// ``` #[inline] #[stable] @@ -470,10 +470,10 @@ impl Option { /// /// ``` /// let x = Some("foo"); - /// assert_eq!(x.ok_or(0i), Ok("foo")); + /// assert_eq!(x.ok_or(0), Ok("foo")); /// /// let x: Option<&str> = None; - /// assert_eq!(x.ok_or(0i), Err(0i)); + /// assert_eq!(x.ok_or(0), Err(0)); /// ``` #[inline] #[unstable] @@ -491,10 +491,10 @@ impl Option { /// /// ``` /// let x = Some("foo"); - /// assert_eq!(x.ok_or_else(|| 0i), Ok("foo")); + /// assert_eq!(x.ok_or_else(|| 0), Ok("foo")); /// /// let x: Option<&str> = None; - /// assert_eq!(x.ok_or_else(|| 0i), Err(0i)); + /// assert_eq!(x.ok_or_else(|| 0), Err(0)); /// ``` #[inline] #[unstable] @@ -514,7 +514,7 @@ impl Option { /// # Example /// /// ``` - /// let x = Some(4u); + /// let x = Some(4); /// assert_eq!(x.iter().next(), Some(&4)); /// /// let x: Option = None; @@ -531,9 +531,9 @@ impl Option { /// # Example /// /// ``` - /// let mut x = Some(4u); + /// let mut x = Some(4); /// match x.iter_mut().next() { - /// Some(&mut ref mut v) => *v = 42u, + /// Some(&mut ref mut v) => *v = 42, /// None => {}, /// } /// assert_eq!(x, Some(42)); @@ -575,7 +575,7 @@ impl Option { /// # Example /// /// ``` - /// let x = Some(2u); + /// let x = Some(2); /// let y: Option<&str> = None; /// assert_eq!(x.and(y), None); /// @@ -583,7 +583,7 @@ impl Option { /// let y = Some("foo"); /// assert_eq!(x.and(y), None); /// - /// let x = Some(2u); + /// let x = Some(2); /// let y = Some("foo"); /// assert_eq!(x.and(y), Some("foo")); /// @@ -628,17 +628,17 @@ impl Option { /// # Example /// /// ``` - /// let x = Some(2u); + /// let x = Some(2); /// let y = None; - /// assert_eq!(x.or(y), Some(2u)); + /// assert_eq!(x.or(y), Some(2)); /// /// let x = None; - /// let y = Some(100u); - /// assert_eq!(x.or(y), Some(100u)); + /// let y = Some(100); + /// assert_eq!(x.or(y), Some(100)); /// - /// let x = Some(2u); - /// let y = Some(100u); - /// assert_eq!(x.or(y), Some(2u)); + /// let x = Some(2); + /// let y = Some(100); + /// assert_eq!(x.or(y), Some(2)); /// /// let x: Option = None; /// let y = None; @@ -684,7 +684,7 @@ impl Option { /// # Example /// /// ``` - /// let mut x = Some(2u); + /// let mut x = Some(2); /// x.take(); /// assert_eq!(x, None); /// @@ -728,8 +728,8 @@ impl Option { /// let good_year = good_year_from_input.parse().unwrap_or_default(); /// let bad_year = bad_year_from_input.parse().unwrap_or_default(); /// - /// assert_eq!(1909i, good_year); - /// assert_eq!(0i, bad_year); + /// assert_eq!(1909, good_year); + /// assert_eq!(0, bad_year); /// ``` #[inline] #[stable] @@ -894,12 +894,12 @@ impl> FromIterator> for Option { /// ```rust /// use std::uint; /// - /// let v = vec!(1u, 2u); + /// let v = vec!(1, 2); /// let res: Option> = v.iter().map(|&x: &uint| /// if x == uint::MAX { None } /// else { Some(x + 1) } /// ).collect(); - /// assert!(res == Some(vec!(2u, 3u))); + /// assert!(res == Some(vec!(2, 3))); /// ``` #[inline] #[stable] diff --git a/src/libcore/result.rs b/src/libcore/result.rs index c3d49e24978..4ea3bf8e5bd 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -482,8 +482,8 @@ impl Result { /// ``` /// fn stringify(x: uint) -> String { format!("error code: {}", x) } /// - /// let x: Result = Ok(2u); - /// assert_eq!(x.map_err(stringify), Ok(2u)); + /// let x: Result = Ok(2); + /// assert_eq!(x.map_err(stringify), Ok(2)); /// /// let x: Result = Err(13); /// assert_eq!(x.map_err(stringify), Err("error code: 13".to_string())); @@ -546,7 +546,7 @@ impl Result { /// ``` /// let x: Result = Ok(5); /// let v: Vec = x.into_iter().collect(); - /// assert_eq!(v, vec![5u]); + /// assert_eq!(v, vec![5]); /// /// let x: Result = Err("nothing!"); /// let v: Vec = x.into_iter().collect(); @@ -676,9 +676,9 @@ impl Result { /// # Example /// /// ``` - /// let optb = 2u; - /// let x: Result = Ok(9u); - /// assert_eq!(x.unwrap_or(optb), 9u); + /// let optb = 2; + /// let x: Result = Ok(9); + /// assert_eq!(x.unwrap_or(optb), 9); /// /// let x: Result = Err("error"); /// assert_eq!(x.unwrap_or(optb), optb); @@ -700,8 +700,8 @@ impl Result { /// ``` /// fn count(x: &str) -> uint { x.len() } /// - /// assert_eq!(Ok(2u).unwrap_or_else(count), 2u); - /// assert_eq!(Err("foo").unwrap_or_else(count), 3u); + /// assert_eq!(Ok(2).unwrap_or_else(count), 2); + /// assert_eq!(Err("foo").unwrap_or_else(count), 3); /// ``` #[inline] #[stable] @@ -725,8 +725,8 @@ impl Result { /// # Example /// /// ``` - /// let x: Result = Ok(2u); - /// assert_eq!(x.unwrap(), 2u); + /// let x: Result = Ok(2); + /// assert_eq!(x.unwrap(), 2); /// ``` /// /// ```{.should_fail} @@ -756,7 +756,7 @@ impl Result { /// # Example /// /// ```{.should_fail} - /// let x: Result = Ok(2u); + /// let x: Result = Ok(2); /// x.unwrap_err(); // panics with `2` /// ``` /// @@ -897,12 +897,12 @@ impl> FromIterator> for Result { /// ```rust /// use std::uint; /// - /// let v = vec!(1u, 2u); + /// let v = vec!(1, 2); /// let res: Result, &'static str> = v.iter().map(|&x: &uint| /// if x == uint::MAX { Err("Overflow!") } /// else { Ok(x + 1) } /// ).collect(); - /// assert!(res == Ok(vec!(2u, 3u))); + /// assert!(res == Ok(vec!(2, 3))); /// ``` #[inline] fn from_iter>>(iter: I) -> Result { diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index ec43a35248e..f08978db8fe 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -653,7 +653,7 @@ macro_rules! iterator { self.ptr = transmute(self.ptr as uint + 1); // Use a non-null pointer value - Some(transmute(1u)) + Some(&mut *(1 as *mut _)) } else { let old = self.ptr; self.ptr = self.ptr.offset(1); @@ -687,7 +687,7 @@ macro_rules! iterator { self.end = transmute(self.end as uint - 1); // Use a non-null pointer value - Some(transmute(1u)) + Some(&mut *(1 as *mut _)) } else { self.end = self.end.offset(-1); @@ -795,7 +795,7 @@ impl<'a, T> RandomAccessIterator for Iter<'a, T> { if index < self.indexable() { if mem::size_of::() == 0 { // Use a non-null pointer value - Some(transmute(1u)) + Some(&mut *(1 as *mut _)) } else { Some(transmute(self.ptr.offset(index as int))) } @@ -1175,7 +1175,7 @@ impl<'a, T> Iterator for Windows<'a, T> { (0, Some(0)) } else { let x = self.v.len() - self.size; - (x.saturating_add(1), x.checked_add(1u)) + (x.saturating_add(1), x.checked_add(1)) } } } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 1e01da4e41d..b0227c749cc 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -198,9 +198,9 @@ pub unsafe fn from_utf8_unchecked<'a>(v: &'a [u8]) -> &'a str { #[deprecated = "use std::ffi::c_str_to_bytes + str::from_utf8"] pub unsafe fn from_c_str(s: *const i8) -> &'static str { let s = s as *const u8; - let mut len = 0u; + let mut len = 0; while *s.offset(len as int) != 0 { - len += 1u; + len += 1; } let v: &'static [u8] = ::mem::transmute(Slice { data: s, len: len }); from_utf8(v).ok().expect("from_c_str passed invalid utf-8 data") @@ -1510,7 +1510,7 @@ impl StrExt for str { None => "", Some(last) => { let next = self.char_range_at(last).next; - unsafe { self.slice_unchecked(0u, next) } + unsafe { self.slice_unchecked(0, next) } } } } @@ -1543,7 +1543,7 @@ impl StrExt for str { fn multibyte_char_range_at_reverse(s: &str, mut i: uint) -> CharRange { // while there is a previous byte == 10...... while i > 0 && s.as_bytes()[i] & !CONT_MASK == TAG_CONT_U8 { - i -= 1u; + i -= 1; } let mut val = s.as_bytes()[i] as u32; @@ -1613,7 +1613,7 @@ impl StrExt for str { if self.is_empty() { None } else { - let CharRange {ch, next} = self.char_range_at(0u); + let CharRange {ch, next} = self.char_range_at(0); let next_s = unsafe { self.slice_unchecked(next, self.len()) }; Some((ch, next_s)) }