Auto merge of #21511 - alfie:suffix-cleanup, r=huonw

This commit is contained in:
bors 2015-01-25 00:49:41 +00:00
commit 70b13a7c7c
19 changed files with 128 additions and 128 deletions

View File

@ -589,7 +589,7 @@ impl AtomicUsize {
/// ``` /// ```
/// use std::sync::atomic::AtomicUsize; /// use std::sync::atomic::AtomicUsize;
/// ///
/// let atomic_forty_two = AtomicUsize::new(42u); /// let atomic_forty_two = AtomicUsize::new(42);
/// ``` /// ```
#[inline] #[inline]
pub fn new(v: usize) -> AtomicUsize { pub fn new(v: usize) -> AtomicUsize {
@ -765,7 +765,7 @@ impl<T> AtomicPtr<T> {
/// ``` /// ```
/// use std::sync::atomic::AtomicPtr; /// use std::sync::atomic::AtomicPtr;
/// ///
/// let ptr = &mut 5i; /// let ptr = &mut 5;
/// let atomic_ptr = AtomicPtr::new(ptr); /// let atomic_ptr = AtomicPtr::new(ptr);
/// ``` /// ```
#[inline] #[inline]
@ -787,7 +787,7 @@ impl<T> AtomicPtr<T> {
/// ``` /// ```
/// use std::sync::atomic::{AtomicPtr, Ordering}; /// use std::sync::atomic::{AtomicPtr, Ordering};
/// ///
/// let ptr = &mut 5i; /// let ptr = &mut 5;
/// let some_ptr = AtomicPtr::new(ptr); /// let some_ptr = AtomicPtr::new(ptr);
/// ///
/// let value = some_ptr.load(Ordering::Relaxed); /// let value = some_ptr.load(Ordering::Relaxed);
@ -809,10 +809,10 @@ impl<T> AtomicPtr<T> {
/// ``` /// ```
/// use std::sync::atomic::{AtomicPtr, Ordering}; /// use std::sync::atomic::{AtomicPtr, Ordering};
/// ///
/// let ptr = &mut 5i; /// let ptr = &mut 5;
/// let some_ptr = AtomicPtr::new(ptr); /// let some_ptr = AtomicPtr::new(ptr);
/// ///
/// let other_ptr = &mut 10i; /// let other_ptr = &mut 10;
/// ///
/// some_ptr.store(other_ptr, Ordering::Relaxed); /// some_ptr.store(other_ptr, Ordering::Relaxed);
/// ``` /// ```
@ -835,10 +835,10 @@ impl<T> AtomicPtr<T> {
/// ``` /// ```
/// use std::sync::atomic::{AtomicPtr, Ordering}; /// use std::sync::atomic::{AtomicPtr, Ordering};
/// ///
/// let ptr = &mut 5i; /// let ptr = &mut 5;
/// let some_ptr = AtomicPtr::new(ptr); /// 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); /// let value = some_ptr.swap(other_ptr, Ordering::Relaxed);
/// ``` /// ```
@ -860,11 +860,11 @@ impl<T> AtomicPtr<T> {
/// ``` /// ```
/// use std::sync::atomic::{AtomicPtr, Ordering}; /// use std::sync::atomic::{AtomicPtr, Ordering};
/// ///
/// let ptr = &mut 5i; /// let ptr = &mut 5;
/// let some_ptr = AtomicPtr::new(ptr); /// let some_ptr = AtomicPtr::new(ptr);
/// ///
/// let other_ptr = &mut 10i; /// let other_ptr = &mut 10;
/// let another_ptr = &mut 10i; /// let another_ptr = &mut 10;
/// ///
/// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed); /// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed);
/// ``` /// ```

View File

@ -67,10 +67,10 @@
//! //!
//! fn main() { //! fn main() {
//! let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new())); //! let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new()));
//! shared_map.borrow_mut().insert("africa", 92388i); //! shared_map.borrow_mut().insert("africa", 92388);
//! shared_map.borrow_mut().insert("kyoto", 11837i); //! shared_map.borrow_mut().insert("kyoto", 11837);
//! shared_map.borrow_mut().insert("piccadilly", 11826i); //! shared_map.borrow_mut().insert("piccadilly", 11826);
//! shared_map.borrow_mut().insert("marbles", 38i); //! shared_map.borrow_mut().insert("marbles", 38);
//! } //! }
//! ``` //! ```
//! //!

View File

@ -102,7 +102,7 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
if num < 10 { if num < 10 {
Some(transmute(('0' as uint + num) as u32)) Some(transmute(('0' as uint + num) as u32))
} else { } else {
Some(transmute(('a' as uint + num - 10u) as u32)) Some(transmute(('a' as uint + num - 10) as u32))
} }
} }
} else { } else {
@ -208,8 +208,8 @@ impl CharExt for char {
} }
let val = match self { let val = match self {
'0' ... '9' => self as uint - ('0' as uint), '0' ... '9' => self as uint - ('0' 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 + 10u - ('A' as uint), 'A' ... 'Z' => self as uint + 10 - ('A' as uint),
_ => return None, _ => return None,
}; };
if val < radix { Some(val) } if val < radix { Some(val) }
@ -241,10 +241,10 @@ impl CharExt for char {
fn len_utf8(self) -> uint { fn len_utf8(self) -> uint {
let code = self as u32; let code = self as u32;
match () { match () {
_ if code < MAX_ONE_B => 1u, _ if code < MAX_ONE_B => 1,
_ if code < MAX_TWO_B => 2u, _ if code < MAX_TWO_B => 2,
_ if code < MAX_THREE_B => 3u, _ if code < MAX_THREE_B => 3,
_ => 4u, _ => 4,
} }
} }
@ -359,7 +359,7 @@ impl Iterator for EscapeUnicode {
Some('u') Some('u')
} }
EscapeUnicodeState::LeftBrace => { EscapeUnicodeState::LeftBrace => {
let mut n = 0u; let mut n = 0;
while (self.c as u32) >> (4 * (n + 1)) != 0 { while (self.c as u32) >> (4 * (n + 1)) != 0 {
n += 1; n += 1;
} }

View File

@ -110,13 +110,13 @@ pub trait Eq: PartialEq<Self> {
pub enum Ordering { pub enum Ordering {
/// An ordering where a compared value is less [than another]. /// An ordering where a compared value is less [than another].
#[stable] #[stable]
Less = -1i, Less = -1,
/// An ordering where a compared value is equal [to another]. /// An ordering where a compared value is equal [to another].
#[stable] #[stable]
Equal = 0i, Equal = 0,
/// An ordering where a compared value is greater [than another]. /// An ordering where a compared value is greater [than another].
#[stable] #[stable]
Greater = 1i, Greater = 1,
} }
impl Ordering { impl Ordering {
@ -132,12 +132,12 @@ impl Ordering {
/// assert_eq!(Equal.reverse(), Equal); /// assert_eq!(Equal.reverse(), Equal);
/// assert_eq!(Greater.reverse(), Less); /// 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. /// // sort the array from largest to smallest.
/// data.sort_by(|a, b| a.cmp(b).reverse()); /// 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); /// assert!(data == b);
/// ``` /// ```
#[inline] #[inline]
@ -174,9 +174,9 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// ``` /// ```
/// use std::cmp::Ordering::{Less, Equal, Greater}; /// use std::cmp::Ordering::{Less, Equal, Greater};
/// ///
/// assert_eq!( 5u.cmp(&10), Less); // because 5 < 10 /// assert_eq!( 5.cmp(&10), Less); // because 5 < 10
/// assert_eq!(10u.cmp(&5), Greater); // because 10 > 5 /// assert_eq!(10.cmp(&5), Greater); // because 10 > 5
/// assert_eq!( 5u.cmp(&5), Equal); // because 5 == 5 /// assert_eq!( 5.cmp(&5), Equal); // because 5 == 5
/// ``` /// ```
#[stable] #[stable]
fn cmp(&self, other: &Self) -> Ordering; fn cmp(&self, other: &Self) -> Ordering;

View File

@ -150,17 +150,17 @@ default_impl! { (), () }
default_impl! { bool, false } default_impl! { bool, false }
default_impl! { char, '\x00' } default_impl! { char, '\x00' }
default_impl! { uint, 0u } default_impl! { uint, 0 }
default_impl! { u8, 0u8 } default_impl! { u8, 0 }
default_impl! { u16, 0u16 } default_impl! { u16, 0 }
default_impl! { u32, 0u32 } default_impl! { u32, 0 }
default_impl! { u64, 0u64 } default_impl! { u64, 0 }
default_impl! { int, 0i } default_impl! { int, 0 }
default_impl! { i8, 0i8 } default_impl! { i8, 0 }
default_impl! { i16, 0i16 } default_impl! { i16, 0 }
default_impl! { i32, 0i32 } default_impl! { i32, 0 }
default_impl! { i64, 0i64 } default_impl! { i64, 0 }
default_impl! { f32, 0.0f32 } default_impl! { f32, 0.0f32 }
default_impl! { f64, 0.0f64 } default_impl! { f64, 0.0f64 }

View File

@ -53,7 +53,7 @@ pub enum SignFormat {
SignNeg 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. /// Converts a number to its string representation as a byte vector.
/// This is meant to be a common base implementation for all numeric string /// This is meant to be a common base implementation for all numeric string
@ -191,7 +191,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
if deccum != _0 || (limit_digits && exact && digit_count > 0) { if deccum != _0 || (limit_digits && exact && digit_count > 0) {
buf[end] = b'.'; buf[end] = b'.';
end += 1; end += 1;
let mut dig = 0u; let mut dig = 0;
// calculate new digits while // calculate new digits while
// - there is no limit and there are digits left // - there is no limit and there are digits left
@ -218,7 +218,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
// Decrease the deccumulator one fractional digit at a time // Decrease the deccumulator one fractional digit at a time
deccum = deccum.fract(); deccum = deccum.fract();
dig += 1u; dig += 1;
} }
// If digits are limited, and that limit has been reached, // If digits are limited, and that limit has been reached,

View File

@ -560,8 +560,8 @@ impl<'a> Formatter<'a> {
}; };
let (pre_pad, post_pad) = match align { let (pre_pad, post_pad) = match align {
rt::AlignLeft => (0u, padding), rt::AlignLeft => (0, padding),
rt::AlignRight | rt::AlignUnknown => (padding, 0u), rt::AlignRight | rt::AlignUnknown => (padding, 0),
rt::AlignCenter => (padding / 2, (padding + 1) / 2), rt::AlignCenter => (padding / 2, (padding + 1) / 2),
}; };
@ -846,7 +846,7 @@ macro_rules! tuple {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
try!(write!(f, "(")); try!(write!(f, "("));
let ($(ref $name,)*) = *self; let ($(ref $name,)*) = *self;
let mut n = 0i; let mut n = 0;
$( $(
if n > 0 { if n > 0 {
try!(write!(f, ", ")); try!(write!(f, ", "));

View File

@ -145,7 +145,7 @@ pub struct RadixFmt<T, R>(T, R);
/// ///
/// ``` /// ```
/// use std::fmt::radix; /// 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"] #[unstable = "may be renamed or move to a different module"]
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> { pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {

View File

@ -122,7 +122,7 @@ impl Writer for SipHasher {
let length = msg.len(); let length = msg.len();
self.length += length; self.length += length;
let mut needed = 0u; let mut needed = 0;
if self.ntail != 0 { if self.ntail != 0 {
needed = 8 - self.ntail; needed = 8 - self.ntail;

View File

@ -33,7 +33,7 @@
//! translated to the `loop` below. //! translated to the `loop` below.
//! //!
//! ``` //! ```
//! let values = vec![1i, 2, 3]; //! let values = vec![1, 2, 3];
//! //!
//! // "Syntactical sugar" taking advantage of an iterator //! // "Syntactical sugar" taking advantage of an iterator
//! for &x in values.iter() { //! for &x in values.iter() {
@ -615,7 +615,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # 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 > 0));
/// assert!(!a.iter().all(|x| *x > 2)); /// assert!(!a.iter().all(|x| *x > 2));
/// ``` /// ```
@ -1141,7 +1141,7 @@ pub trait AdditiveIterator<A> {
/// ``` /// ```
/// use std::iter::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); /// let mut it = a.iter().map(|&x| x);
/// assert!(it.sum() == 15); /// assert!(it.sum() == 15);
/// ``` /// ```
@ -1183,7 +1183,7 @@ pub trait MultiplicativeIterator<A> {
/// use std::iter::{count, MultiplicativeIterator}; /// use std::iter::{count, MultiplicativeIterator};
/// ///
/// fn factorial(n: usize) -> usize { /// 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(0) == 1);
/// assert!(factorial(1) == 1); /// assert!(factorial(1) == 1);
@ -2526,7 +2526,7 @@ pub struct Range<A> {
/// ``` /// ```
/// let array = [0, 1, 2, 3, 4]; /// let array = [0, 1, 2, 3, 4];
/// ///
/// for i in range(0, 5u) { /// for i in range(0, 5) {
/// println!("{}", i); /// println!("{}", i);
/// assert_eq!(i, array[i]); /// assert_eq!(i, array[i]);
/// } /// }

View File

@ -48,7 +48,7 @@ macro_rules! panic {
/// let x = true; /// let x = true;
/// assert!(x, "x wasn't 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); /// assert!(a + b == 30, "a = {}, b = {}", a, b);
/// ``` /// ```
#[macro_export] #[macro_export]
@ -74,8 +74,8 @@ macro_rules! assert {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let a = 3i; /// let a = 3;
/// let b = 1i + 2i; /// let b = 1 + 2;
/// assert_eq!(a, b); /// assert_eq!(a, b);
/// ``` /// ```
#[macro_export] #[macro_export]
@ -141,8 +141,8 @@ macro_rules! debug_assert {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let a = 3i; /// let a = 3;
/// let b = 1i + 2i; /// let b = 1 + 2;
/// debug_assert_eq!(a, b); /// debug_assert_eq!(a, b);
/// ``` /// ```
#[macro_export] #[macro_export]

View File

@ -187,13 +187,13 @@ pub unsafe fn uninitialized<T>() -> T {
/// ``` /// ```
/// use std::mem; /// use std::mem;
/// ///
/// let x = &mut 5i; /// let x = &mut 5;
/// let y = &mut 42i; /// let y = &mut 42;
/// ///
/// mem::swap(x, y); /// mem::swap(x, y);
/// ///
/// assert_eq!(42i, *x); /// assert_eq!(42, *x);
/// assert_eq!(5i, *y); /// assert_eq!(5, *y);
/// ``` /// ```
#[inline] #[inline]
#[stable] #[stable]
@ -277,7 +277,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
/// ``` /// ```
/// use std::cell::RefCell; /// use std::cell::RefCell;
/// ///
/// let x = RefCell::new(1i); /// let x = RefCell::new(1);
/// ///
/// let mut mutable_borrow = x.borrow_mut(); /// let mut mutable_borrow = x.borrow_mut();
/// *mutable_borrow = 1; /// *mutable_borrow = 1;
@ -306,9 +306,9 @@ pub fn drop<T>(_x: T) { }
/// ``` /// ```
/// use std::mem; /// 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] #[inline]
#[stable] #[stable]

View File

@ -23,12 +23,12 @@ use num::FpCategory as Fp;
use option::Option; use option::Option;
#[unstable = "pending integer conventions"] #[unstable = "pending integer conventions"]
pub const RADIX: uint = 2u; pub const RADIX: uint = 2;
#[unstable = "pending integer conventions"] #[unstable = "pending integer conventions"]
pub const MANTISSA_DIGITS: uint = 24u; pub const MANTISSA_DIGITS: uint = 24;
#[unstable = "pending integer conventions"] #[unstable = "pending integer conventions"]
pub const DIGITS: uint = 6u; pub const DIGITS: uint = 6;
#[stable] #[stable]
pub const EPSILON: f32 = 1.19209290e-07_f32; pub const EPSILON: f32 = 1.19209290e-07_f32;

View File

@ -27,11 +27,11 @@ use option::Option;
// members of `Bounded` and `Float`. // members of `Bounded` and `Float`.
#[unstable = "pending integer conventions"] #[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"] #[unstable = "pending integer conventions"]
pub const DIGITS: uint = 15u; pub const DIGITS: uint = 15;
#[stable] #[stable]
pub const EPSILON: f64 = 2.2204460492503131e-16_f64; pub const EPSILON: f64 = 2.2204460492503131e-16_f64;

View File

@ -356,7 +356,7 @@ pub trait Int
/// ```rust /// ```rust
/// use std::num::Int; /// use std::num::Int;
/// ///
/// assert_eq!(2i.pow(4), 16); /// assert_eq!(2.pow(4), 16);
/// ``` /// ```
#[unstable = "pending integer conventions"] #[unstable = "pending integer conventions"]
#[inline] #[inline]
@ -1185,7 +1185,7 @@ impl_from_primitive! { f64, to_f64 }
/// ``` /// ```
/// use std::num; /// use std::num;
/// ///
/// let twenty: f32 = num::cast(0x14i).unwrap(); /// let twenty: f32 = num::cast(0x14).unwrap();
/// assert_eq!(twenty, 20f32); /// assert_eq!(twenty, 20f32);
/// ``` /// ```
/// ///
@ -1571,8 +1571,8 @@ macro_rules! from_str_radix_float_impl {
let exp = match exp_info { let exp = match exp_info {
Some((c, offset)) => { Some((c, offset)) => {
let base = match c { let base = match c {
'E' | 'e' if radix == 10 => 10u as $T, 'E' | 'e' if radix == 10 => 10.0,
'P' | 'p' if radix == 16 => 2u as $T, 'P' | 'p' if radix == 16 => 2.0,
_ => return None, _ => return None,
}; };

View File

@ -254,12 +254,12 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let mut x = Some(2u); /// let mut x = Some(2);
/// match x.as_mut() { /// match x.as_mut() {
/// Some(v) => *v = 42, /// Some(v) => *v = 42,
/// None => {}, /// None => {},
/// } /// }
/// assert_eq!(x, Some(42u)); /// assert_eq!(x, Some(42));
/// ``` /// ```
#[inline] #[inline]
#[stable] #[stable]
@ -384,9 +384,9 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let k = 10u; /// let k = 10i32;
/// assert_eq!(Some(4u).unwrap_or_else(|| 2 * k), 4u); /// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);
/// assert_eq!(None.unwrap_or_else(|| 2 * k), 20u); /// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);
/// ``` /// ```
#[inline] #[inline]
#[stable] #[stable]
@ -427,10 +427,10 @@ impl<T> Option<T> {
/// ///
/// ``` /// ```
/// let x = Some("foo"); /// 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; /// 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] #[inline]
#[stable] #[stable]
@ -446,13 +446,13 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let k = 21u; /// let k = 21;
/// ///
/// let x = Some("foo"); /// 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; /// 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] #[inline]
#[stable] #[stable]
@ -470,10 +470,10 @@ impl<T> Option<T> {
/// ///
/// ``` /// ```
/// let x = Some("foo"); /// 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; /// let x: Option<&str> = None;
/// assert_eq!(x.ok_or(0i), Err(0i)); /// assert_eq!(x.ok_or(0), Err(0));
/// ``` /// ```
#[inline] #[inline]
#[unstable] #[unstable]
@ -491,10 +491,10 @@ impl<T> Option<T> {
/// ///
/// ``` /// ```
/// let x = Some("foo"); /// 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; /// let x: Option<&str> = None;
/// assert_eq!(x.ok_or_else(|| 0i), Err(0i)); /// assert_eq!(x.ok_or_else(|| 0), Err(0));
/// ``` /// ```
#[inline] #[inline]
#[unstable] #[unstable]
@ -514,7 +514,7 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let x = Some(4u); /// let x = Some(4);
/// assert_eq!(x.iter().next(), Some(&4)); /// assert_eq!(x.iter().next(), Some(&4));
/// ///
/// let x: Option<uint> = None; /// let x: Option<uint> = None;
@ -531,9 +531,9 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let mut x = Some(4u); /// let mut x = Some(4);
/// match x.iter_mut().next() { /// match x.iter_mut().next() {
/// Some(&mut ref mut v) => *v = 42u, /// Some(&mut ref mut v) => *v = 42,
/// None => {}, /// None => {},
/// } /// }
/// assert_eq!(x, Some(42)); /// assert_eq!(x, Some(42));
@ -575,7 +575,7 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let x = Some(2u); /// let x = Some(2);
/// let y: Option<&str> = None; /// let y: Option<&str> = None;
/// assert_eq!(x.and(y), None); /// assert_eq!(x.and(y), None);
/// ///
@ -583,7 +583,7 @@ impl<T> Option<T> {
/// let y = Some("foo"); /// let y = Some("foo");
/// assert_eq!(x.and(y), None); /// assert_eq!(x.and(y), None);
/// ///
/// let x = Some(2u); /// let x = Some(2);
/// let y = Some("foo"); /// let y = Some("foo");
/// assert_eq!(x.and(y), Some("foo")); /// assert_eq!(x.and(y), Some("foo"));
/// ///
@ -628,17 +628,17 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let x = Some(2u); /// let x = Some(2);
/// let y = None; /// let y = None;
/// assert_eq!(x.or(y), Some(2u)); /// assert_eq!(x.or(y), Some(2));
/// ///
/// let x = None; /// let x = None;
/// let y = Some(100u); /// let y = Some(100);
/// assert_eq!(x.or(y), Some(100u)); /// assert_eq!(x.or(y), Some(100));
/// ///
/// let x = Some(2u); /// let x = Some(2);
/// let y = Some(100u); /// let y = Some(100);
/// assert_eq!(x.or(y), Some(2u)); /// assert_eq!(x.or(y), Some(2));
/// ///
/// let x: Option<uint> = None; /// let x: Option<uint> = None;
/// let y = None; /// let y = None;
@ -684,7 +684,7 @@ impl<T> Option<T> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let mut x = Some(2u); /// let mut x = Some(2);
/// x.take(); /// x.take();
/// assert_eq!(x, None); /// assert_eq!(x, None);
/// ///
@ -728,8 +728,8 @@ impl<T: Default> Option<T> {
/// let good_year = good_year_from_input.parse().unwrap_or_default(); /// let good_year = good_year_from_input.parse().unwrap_or_default();
/// let bad_year = bad_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!(1909, good_year);
/// assert_eq!(0i, bad_year); /// assert_eq!(0, bad_year);
/// ``` /// ```
#[inline] #[inline]
#[stable] #[stable]
@ -894,12 +894,12 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
/// ```rust /// ```rust
/// use std::uint; /// use std::uint;
/// ///
/// let v = vec!(1u, 2u); /// let v = vec!(1, 2);
/// let res: Option<Vec<uint>> = v.iter().map(|&x: &uint| /// let res: Option<Vec<uint>> = v.iter().map(|&x: &uint|
/// if x == uint::MAX { None } /// if x == uint::MAX { None }
/// else { Some(x + 1) } /// else { Some(x + 1) }
/// ).collect(); /// ).collect();
/// assert!(res == Some(vec!(2u, 3u))); /// assert!(res == Some(vec!(2, 3)));
/// ``` /// ```
#[inline] #[inline]
#[stable] #[stable]

View File

@ -482,8 +482,8 @@ impl<T, E> Result<T, E> {
/// ``` /// ```
/// fn stringify(x: uint) -> String { format!("error code: {}", x) } /// fn stringify(x: uint) -> String { format!("error code: {}", x) }
/// ///
/// let x: Result<uint, uint> = Ok(2u); /// let x: Result<uint, uint> = Ok(2);
/// assert_eq!(x.map_err(stringify), Ok(2u)); /// assert_eq!(x.map_err(stringify), Ok(2));
/// ///
/// let x: Result<uint, uint> = Err(13); /// let x: Result<uint, uint> = Err(13);
/// assert_eq!(x.map_err(stringify), Err("error code: 13".to_string())); /// assert_eq!(x.map_err(stringify), Err("error code: 13".to_string()));
@ -546,7 +546,7 @@ impl<T, E> Result<T, E> {
/// ``` /// ```
/// let x: Result<uint, &str> = Ok(5); /// let x: Result<uint, &str> = Ok(5);
/// let v: Vec<uint> = x.into_iter().collect(); /// let v: Vec<uint> = x.into_iter().collect();
/// assert_eq!(v, vec![5u]); /// assert_eq!(v, vec![5]);
/// ///
/// let x: Result<uint, &str> = Err("nothing!"); /// let x: Result<uint, &str> = Err("nothing!");
/// let v: Vec<uint> = x.into_iter().collect(); /// let v: Vec<uint> = x.into_iter().collect();
@ -676,9 +676,9 @@ impl<T, E> Result<T, E> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let optb = 2u; /// let optb = 2;
/// let x: Result<uint, &str> = Ok(9u); /// let x: Result<uint, &str> = Ok(9);
/// assert_eq!(x.unwrap_or(optb), 9u); /// assert_eq!(x.unwrap_or(optb), 9);
/// ///
/// let x: Result<uint, &str> = Err("error"); /// let x: Result<uint, &str> = Err("error");
/// assert_eq!(x.unwrap_or(optb), optb); /// assert_eq!(x.unwrap_or(optb), optb);
@ -700,8 +700,8 @@ impl<T, E> Result<T, E> {
/// ``` /// ```
/// fn count(x: &str) -> uint { x.len() } /// fn count(x: &str) -> uint { x.len() }
/// ///
/// assert_eq!(Ok(2u).unwrap_or_else(count), 2u); /// assert_eq!(Ok(2).unwrap_or_else(count), 2);
/// assert_eq!(Err("foo").unwrap_or_else(count), 3u); /// assert_eq!(Err("foo").unwrap_or_else(count), 3);
/// ``` /// ```
#[inline] #[inline]
#[stable] #[stable]
@ -725,8 +725,8 @@ impl<T, E: Display> Result<T, E> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let x: Result<uint, &str> = Ok(2u); /// let x: Result<uint, &str> = Ok(2);
/// assert_eq!(x.unwrap(), 2u); /// assert_eq!(x.unwrap(), 2);
/// ``` /// ```
/// ///
/// ```{.should_fail} /// ```{.should_fail}
@ -756,7 +756,7 @@ impl<T: Display, E> Result<T, E> {
/// # Example /// # Example
/// ///
/// ```{.should_fail} /// ```{.should_fail}
/// let x: Result<uint, &str> = Ok(2u); /// let x: Result<uint, &str> = Ok(2);
/// x.unwrap_err(); // panics with `2` /// x.unwrap_err(); // panics with `2`
/// ``` /// ```
/// ///
@ -897,12 +897,12 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
/// ```rust /// ```rust
/// use std::uint; /// use std::uint;
/// ///
/// let v = vec!(1u, 2u); /// let v = vec!(1, 2);
/// let res: Result<Vec<uint>, &'static str> = v.iter().map(|&x: &uint| /// let res: Result<Vec<uint>, &'static str> = v.iter().map(|&x: &uint|
/// if x == uint::MAX { Err("Overflow!") } /// if x == uint::MAX { Err("Overflow!") }
/// else { Ok(x + 1) } /// else { Ok(x + 1) }
/// ).collect(); /// ).collect();
/// assert!(res == Ok(vec!(2u, 3u))); /// assert!(res == Ok(vec!(2, 3)));
/// ``` /// ```
#[inline] #[inline]
fn from_iter<I: Iterator<Item=Result<A, E>>>(iter: I) -> Result<V, E> { fn from_iter<I: Iterator<Item=Result<A, E>>>(iter: I) -> Result<V, E> {

View File

@ -653,7 +653,7 @@ macro_rules! iterator {
self.ptr = transmute(self.ptr as uint + 1); self.ptr = transmute(self.ptr as uint + 1);
// Use a non-null pointer value // Use a non-null pointer value
Some(transmute(1u)) Some(&mut *(1 as *mut _))
} else { } else {
let old = self.ptr; let old = self.ptr;
self.ptr = self.ptr.offset(1); self.ptr = self.ptr.offset(1);
@ -687,7 +687,7 @@ macro_rules! iterator {
self.end = transmute(self.end as uint - 1); self.end = transmute(self.end as uint - 1);
// Use a non-null pointer value // Use a non-null pointer value
Some(transmute(1u)) Some(&mut *(1 as *mut _))
} else { } else {
self.end = self.end.offset(-1); self.end = self.end.offset(-1);
@ -795,7 +795,7 @@ impl<'a, T> RandomAccessIterator for Iter<'a, T> {
if index < self.indexable() { if index < self.indexable() {
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
// Use a non-null pointer value // Use a non-null pointer value
Some(transmute(1u)) Some(&mut *(1 as *mut _))
} else { } else {
Some(transmute(self.ptr.offset(index as int))) Some(transmute(self.ptr.offset(index as int)))
} }
@ -1175,7 +1175,7 @@ impl<'a, T> Iterator for Windows<'a, T> {
(0, Some(0)) (0, Some(0))
} else { } else {
let x = self.v.len() - self.size; let x = self.v.len() - self.size;
(x.saturating_add(1), x.checked_add(1u)) (x.saturating_add(1), x.checked_add(1))
} }
} }
} }

View File

@ -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"] #[deprecated = "use std::ffi::c_str_to_bytes + str::from_utf8"]
pub unsafe fn from_c_str(s: *const i8) -> &'static str { pub unsafe fn from_c_str(s: *const i8) -> &'static str {
let s = s as *const u8; let s = s as *const u8;
let mut len = 0u; let mut len = 0;
while *s.offset(len as int) != 0 { while *s.offset(len as int) != 0 {
len += 1u; len += 1;
} }
let v: &'static [u8] = ::mem::transmute(Slice { data: s, len: len }); let v: &'static [u8] = ::mem::transmute(Slice { data: s, len: len });
from_utf8(v).ok().expect("from_c_str passed invalid utf-8 data") from_utf8(v).ok().expect("from_c_str passed invalid utf-8 data")
@ -1510,7 +1510,7 @@ impl StrExt for str {
None => "", None => "",
Some(last) => { Some(last) => {
let next = self.char_range_at(last).next; 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 { fn multibyte_char_range_at_reverse(s: &str, mut i: uint) -> CharRange {
// while there is a previous byte == 10...... // while there is a previous byte == 10......
while i > 0 && s.as_bytes()[i] & !CONT_MASK == TAG_CONT_U8 { 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; let mut val = s.as_bytes()[i] as u32;
@ -1613,7 +1613,7 @@ impl StrExt for str {
if self.is_empty() { if self.is_empty() {
None None
} else { } 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()) }; let next_s = unsafe { self.slice_unchecked(next, self.len()) };
Some((ch, next_s)) Some((ch, next_s))
} }