Revert "Remove i suffix in docs"
This reverts commit f031671c6e
.
Conflicts:
src/libcollections/slice.rs
src/libcore/iter.rs
src/libstd/sync/mpsc/mod.rs
src/libstd/sync/rwlock.rs
This commit is contained in:
parent
f331c56869
commit
ee9921aaed
@ -35,7 +35,7 @@
|
||||
//! use std::sync::Arc;
|
||||
//! use std::thread::Thread;
|
||||
//!
|
||||
//! let five = Arc::new(5);
|
||||
//! let five = Arc::new(5i);
|
||||
//!
|
||||
//! for i in range(0u, 10) {
|
||||
//! let five = five.clone();
|
||||
@ -52,7 +52,7 @@
|
||||
//! use std::sync::{Arc, Mutex};
|
||||
//! use std::thread::Thread;
|
||||
//!
|
||||
//! let five = Arc::new(Mutex::new(5));
|
||||
//! let five = Arc::new(Mutex::new(5i));
|
||||
//!
|
||||
//! for _ in range(0u, 10) {
|
||||
//! let five = five.clone();
|
||||
@ -154,7 +154,7 @@ impl<T> Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable]
|
||||
@ -176,7 +176,7 @@ impl<T> Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
/// ```
|
||||
@ -220,7 +220,7 @@ impl<T> Clone for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five.clone();
|
||||
/// ```
|
||||
@ -267,7 +267,7 @@ impl<T: Send + Sync + Clone> Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let mut five = Arc::new(5);
|
||||
/// let mut five = Arc::new(5i);
|
||||
///
|
||||
/// let mut_five = five.make_unique();
|
||||
/// ```
|
||||
@ -303,14 +303,14 @@ impl<T: Sync + Send> Drop for Arc<T> {
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
/// drop(five); // explict drop
|
||||
/// }
|
||||
/// {
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
@ -369,7 +369,7 @@ impl<T: Sync + Send> Weak<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
@ -405,7 +405,7 @@ impl<T: Sync + Send> Clone for Weak<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let weak_five = Arc::new(5).downgrade();
|
||||
/// let weak_five = Arc::new(5i).downgrade();
|
||||
///
|
||||
/// weak_five.clone();
|
||||
/// ```
|
||||
@ -430,7 +430,7 @@ impl<T: Sync + Send> Drop for Weak<T> {
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
/// // stuff
|
||||
@ -438,7 +438,7 @@ impl<T: Sync + Send> Drop for Weak<T> {
|
||||
/// drop(weak_five); // explict drop
|
||||
/// }
|
||||
/// {
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
/// // stuff
|
||||
@ -472,9 +472,9 @@ impl<T: PartialEq> PartialEq for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five == Arc::new(5);
|
||||
/// five == Arc::new(5i);
|
||||
/// ```
|
||||
fn eq(&self, other: &Arc<T>) -> bool { *(*self) == *(*other) }
|
||||
|
||||
@ -487,9 +487,9 @@ impl<T: PartialEq> PartialEq for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five != Arc::new(5);
|
||||
/// five != Arc::new(5i);
|
||||
/// ```
|
||||
fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) }
|
||||
}
|
||||
@ -504,9 +504,9 @@ impl<T: PartialOrd> PartialOrd for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five.partial_cmp(&Arc::new(5));
|
||||
/// five.partial_cmp(&Arc::new(5i));
|
||||
/// ```
|
||||
fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering> {
|
||||
(**self).partial_cmp(&**other)
|
||||
@ -521,9 +521,9 @@ impl<T: PartialOrd> PartialOrd for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five < Arc::new(5);
|
||||
/// five < Arc::new(5i);
|
||||
/// ```
|
||||
fn lt(&self, other: &Arc<T>) -> bool { *(*self) < *(*other) }
|
||||
|
||||
@ -536,9 +536,9 @@ impl<T: PartialOrd> PartialOrd for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five <= Arc::new(5);
|
||||
/// five <= Arc::new(5i);
|
||||
/// ```
|
||||
fn le(&self, other: &Arc<T>) -> bool { *(*self) <= *(*other) }
|
||||
|
||||
@ -551,9 +551,9 @@ impl<T: PartialOrd> PartialOrd for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five > Arc::new(5);
|
||||
/// five > Arc::new(5i);
|
||||
/// ```
|
||||
fn gt(&self, other: &Arc<T>) -> bool { *(*self) > *(*other) }
|
||||
|
||||
@ -566,9 +566,9 @@ impl<T: PartialOrd> PartialOrd for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5);
|
||||
/// let five = Arc::new(5i);
|
||||
///
|
||||
/// five >= Arc::new(5);
|
||||
/// five >= Arc::new(5i);
|
||||
/// ```
|
||||
fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) }
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ impl<T> Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn new(value: T) -> Rc<T> {
|
||||
@ -214,7 +214,7 @@ impl<T> Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
/// ```
|
||||
@ -247,7 +247,7 @@ pub fn strong_count<T>(this: &Rc<T>) -> uint { this.strong() }
|
||||
/// use std::rc;
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// rc::is_unique(&five);
|
||||
/// ```
|
||||
@ -329,7 +329,7 @@ impl<T: Clone> Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let mut five = Rc::new(5);
|
||||
/// let mut five = Rc::new(5i);
|
||||
///
|
||||
/// let mut_five = five.make_unique();
|
||||
/// ```
|
||||
@ -378,14 +378,14 @@ impl<T> Drop for Rc<T> {
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
/// drop(five); // explict drop
|
||||
/// }
|
||||
/// {
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
@ -424,7 +424,7 @@ impl<T> Clone for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five.clone();
|
||||
/// ```
|
||||
@ -465,9 +465,9 @@ impl<T: PartialEq> PartialEq for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five == Rc::new(5);
|
||||
/// five == Rc::new(5i);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &Rc<T>) -> bool { **self == **other }
|
||||
@ -481,9 +481,9 @@ impl<T: PartialEq> PartialEq for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five != Rc::new(5);
|
||||
/// five != Rc::new(5i);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
|
||||
@ -503,9 +503,9 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five.partial_cmp(&Rc::new(5));
|
||||
/// five.partial_cmp(&Rc::new(5i));
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn partial_cmp(&self, other: &Rc<T>) -> Option<Ordering> {
|
||||
@ -521,9 +521,9 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five < Rc::new(5);
|
||||
/// five < Rc::new(5i);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
|
||||
@ -537,9 +537,9 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five <= Rc::new(5);
|
||||
/// five <= Rc::new(5i);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn le(&self, other: &Rc<T>) -> bool { **self <= **other }
|
||||
@ -553,9 +553,9 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five > Rc::new(5);
|
||||
/// five > Rc::new(5i);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn gt(&self, other: &Rc<T>) -> bool { **self > **other }
|
||||
@ -569,9 +569,9 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five >= Rc::new(5);
|
||||
/// five >= Rc::new(5i);
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
fn ge(&self, other: &Rc<T>) -> bool { **self >= **other }
|
||||
@ -588,9 +588,9 @@ impl<T: Ord> Ord for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// five.partial_cmp(&Rc::new(5));
|
||||
/// five.partial_cmp(&Rc::new(5i));
|
||||
/// ```
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
|
||||
@ -639,7 +639,7 @@ impl<T> Weak<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
@ -668,7 +668,7 @@ impl<T> Drop for Weak<T> {
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
/// // stuff
|
||||
@ -676,7 +676,7 @@ impl<T> Drop for Weak<T> {
|
||||
/// drop(weak_five); // explict drop
|
||||
/// }
|
||||
/// {
|
||||
/// let five = Rc::new(5);
|
||||
/// let five = Rc::new(5i);
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
/// // stuff
|
||||
@ -710,7 +710,7 @@ impl<T> Clone for Weak<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let weak_five = Rc::new(5).downgrade();
|
||||
/// let weak_five = Rc::new(5i).downgrade();
|
||||
///
|
||||
/// weak_five.clone();
|
||||
/// ```
|
||||
|
@ -212,7 +212,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![9i, 1, 2, 7, 3, 2]);
|
||||
/// ```
|
||||
pub fn from_vec(vec: Vec<T>) -> BinaryHeap<T> {
|
||||
let mut heap = BinaryHeap { data: vec };
|
||||
@ -231,7 +231,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![1i, 2, 3, 4]);
|
||||
///
|
||||
/// // Print 1, 2, 3, 4 in arbitrary order
|
||||
/// for x in heap.iter() {
|
||||
@ -251,7 +251,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![1i, 2, 3, 4]);
|
||||
///
|
||||
/// // Print 1, 2, 3, 4 in arbitrary order
|
||||
/// for x in heap.into_iter() {
|
||||
@ -273,7 +273,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
/// assert_eq!(heap.peek(), None);
|
||||
///
|
||||
/// heap.push(1);
|
||||
/// heap.push(1i);
|
||||
/// heap.push(5);
|
||||
/// heap.push(2);
|
||||
/// assert_eq!(heap.peek(), Some(&5));
|
||||
@ -356,7 +356,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1i, 3]);
|
||||
///
|
||||
/// assert_eq!(heap.pop(), Some(3));
|
||||
/// assert_eq!(heap.pop(), Some(1));
|
||||
@ -380,7 +380,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
/// heap.push(3);
|
||||
/// heap.push(3i);
|
||||
/// heap.push(5);
|
||||
/// heap.push(1);
|
||||
///
|
||||
@ -402,7 +402,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
/// heap.push(1);
|
||||
/// heap.push(1i);
|
||||
/// heap.push(5);
|
||||
///
|
||||
/// assert_eq!(heap.push_pop(3), 5);
|
||||
@ -434,7 +434,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
///
|
||||
/// assert_eq!(heap.replace(1), None);
|
||||
/// assert_eq!(heap.replace(1i), None);
|
||||
/// assert_eq!(heap.replace(3), Some(1));
|
||||
/// assert_eq!(heap.len(), 1);
|
||||
/// assert_eq!(heap.peek(), Some(&3));
|
||||
@ -457,7 +457,7 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![1i, 2, 3, 4, 5, 6, 7]);
|
||||
/// let vec = heap.into_vec();
|
||||
///
|
||||
/// // Will print in some order
|
||||
@ -475,12 +475,12 @@ impl<T: Ord> BinaryHeap<T> {
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
///
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]);
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1i, 2, 4, 5, 7]);
|
||||
/// heap.push(6);
|
||||
/// heap.push(3);
|
||||
///
|
||||
/// let vec = heap.into_sorted_vec();
|
||||
/// assert_eq!(vec, vec![1, 2, 3, 4, 5, 6, 7]);
|
||||
/// assert_eq!(vec, vec![1i, 2, 3, 4, 5, 6, 7]);
|
||||
/// ```
|
||||
pub fn into_sorted_vec(mut self) -> Vec<T> {
|
||||
let mut end = self.len();
|
||||
|
@ -245,7 +245,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
///
|
||||
/// let mut v = BTreeSet::new();
|
||||
/// assert_eq!(v.len(), 0);
|
||||
/// v.insert(1);
|
||||
/// v.insert(1i);
|
||||
/// assert_eq!(v.len(), 1);
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -260,7 +260,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
///
|
||||
/// let mut v = BTreeSet::new();
|
||||
/// assert!(v.is_empty());
|
||||
/// v.insert(1);
|
||||
/// v.insert(1i);
|
||||
/// assert!(!v.is_empty());
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -274,7 +274,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let mut v = BTreeSet::new();
|
||||
/// v.insert(1);
|
||||
/// v.insert(1i);
|
||||
/// v.clear();
|
||||
/// assert!(v.is_empty());
|
||||
/// ```
|
||||
@ -294,7 +294,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let set: BTreeSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let set: BTreeSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// assert_eq!(set.contains(&1), true);
|
||||
/// assert_eq!(set.contains(&4), false);
|
||||
/// ```
|
||||
@ -311,7 +311,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let a: BTreeSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let a: BTreeSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let mut b: BTreeSet<int> = BTreeSet::new();
|
||||
///
|
||||
/// assert_eq!(a.is_disjoint(&b), true);
|
||||
@ -332,7 +332,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let sup: BTreeSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let sup: BTreeSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let mut set: BTreeSet<int> = BTreeSet::new();
|
||||
///
|
||||
/// assert_eq!(set.is_subset(&sup), true);
|
||||
@ -374,7 +374,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let sub: BTreeSet<int> = [1, 2].iter().map(|&x| x).collect();
|
||||
/// let sub: BTreeSet<int> = [1i, 2].iter().map(|&x| x).collect();
|
||||
/// let mut set: BTreeSet<int> = BTreeSet::new();
|
||||
///
|
||||
/// assert_eq!(set.is_superset(&sub), false);
|
||||
@ -401,8 +401,8 @@ impl<T: Ord> BTreeSet<T> {
|
||||
///
|
||||
/// let mut set = BTreeSet::new();
|
||||
///
|
||||
/// assert_eq!(set.insert(2), true);
|
||||
/// assert_eq!(set.insert(2), false);
|
||||
/// assert_eq!(set.insert(2i), true);
|
||||
/// assert_eq!(set.insert(2i), false);
|
||||
/// assert_eq!(set.len(), 1);
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -424,7 +424,7 @@ impl<T: Ord> BTreeSet<T> {
|
||||
///
|
||||
/// let mut set = BTreeSet::new();
|
||||
///
|
||||
/// set.insert(2);
|
||||
/// set.insert(2i);
|
||||
/// assert_eq!(set.remove(&2), true);
|
||||
/// assert_eq!(set.remove(&2), false);
|
||||
/// ```
|
||||
|
@ -232,9 +232,9 @@ impl<T> DList<T> {
|
||||
///
|
||||
/// let mut a = DList::new();
|
||||
/// let mut b = DList::new();
|
||||
/// a.push_back(1);
|
||||
/// a.push_back(1i);
|
||||
/// a.push_back(2);
|
||||
/// b.push_back(3);
|
||||
/// b.push_back(3i);
|
||||
/// b.push_back(4);
|
||||
///
|
||||
/// a.append(b);
|
||||
@ -377,7 +377,7 @@ impl<T> DList<T> {
|
||||
/// use std::collections::DList;
|
||||
///
|
||||
/// let mut d = DList::new();
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(3);
|
||||
/// assert_eq!(3, *d.back().unwrap());
|
||||
/// ```
|
||||
@ -396,7 +396,7 @@ impl<T> DList<T> {
|
||||
///
|
||||
/// let mut d = DList::new();
|
||||
/// assert_eq!(d.pop_back(), None);
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(3);
|
||||
/// assert_eq!(d.pop_back(), Some(3));
|
||||
/// ```
|
||||
@ -553,7 +553,7 @@ impl<'a, A> IterMut<'a, A> {
|
||||
/// }
|
||||
/// {
|
||||
/// let vec: Vec<int> = list.into_iter().collect();
|
||||
/// assert_eq!(vec, vec![1, 2, 3, 4]);
|
||||
/// assert_eq!(vec, vec![1i, 2, 3, 4]);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -186,7 +186,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(3i);
|
||||
/// buf.push_back(4);
|
||||
/// buf.push_back(5);
|
||||
/// assert_eq!(buf.get(1).unwrap(), &4);
|
||||
@ -209,7 +209,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(3i);
|
||||
/// buf.push_back(4);
|
||||
/// buf.push_back(5);
|
||||
/// match buf.get_mut(1) {
|
||||
@ -243,7 +243,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(3i);
|
||||
/// buf.push_back(4);
|
||||
/// buf.push_back(5);
|
||||
/// buf.swap(0, 2);
|
||||
@ -495,7 +495,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// let b: &[_] = &[&5, &3, &4];
|
||||
@ -518,7 +518,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// for num in buf.iter_mut() {
|
||||
@ -597,7 +597,7 @@ impl<T> RingBuf<T> {
|
||||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// assert_eq!(v.len(), 0);
|
||||
/// v.push_back(1);
|
||||
/// v.push_back(1i);
|
||||
/// assert_eq!(v.len(), 1);
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -612,7 +612,7 @@ impl<T> RingBuf<T> {
|
||||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// assert!(v.is_empty());
|
||||
/// v.push_front(1);
|
||||
/// v.push_front(1i);
|
||||
/// assert!(!v.is_empty());
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -627,7 +627,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// v.push_back(1);
|
||||
/// v.push_back(1i);
|
||||
/// assert_eq!(v.drain().next(), Some(1));
|
||||
/// assert!(v.is_empty());
|
||||
/// ```
|
||||
@ -647,7 +647,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// v.push_back(1);
|
||||
/// v.push_back(1i);
|
||||
/// v.clear();
|
||||
/// assert!(v.is_empty());
|
||||
/// ```
|
||||
@ -668,9 +668,9 @@ impl<T> RingBuf<T> {
|
||||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.front(), None);
|
||||
///
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// assert_eq!(d.front(), Some(&1));
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// assert_eq!(d.front(), Some(&1i));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn front(&self) -> Option<&T> {
|
||||
@ -688,13 +688,13 @@ impl<T> RingBuf<T> {
|
||||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.front_mut(), None);
|
||||
///
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// match d.front_mut() {
|
||||
/// Some(x) => *x = 9,
|
||||
/// Some(x) => *x = 9i,
|
||||
/// None => (),
|
||||
/// }
|
||||
/// assert_eq!(d.front(), Some(&9));
|
||||
/// assert_eq!(d.front(), Some(&9i));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn front_mut(&mut self) -> Option<&mut T> {
|
||||
@ -712,9 +712,9 @@ impl<T> RingBuf<T> {
|
||||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.back(), None);
|
||||
///
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// assert_eq!(d.back(), Some(&2));
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// assert_eq!(d.back(), Some(&2i));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn back(&self) -> Option<&T> {
|
||||
@ -732,13 +732,13 @@ impl<T> RingBuf<T> {
|
||||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.back(), None);
|
||||
///
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// match d.back_mut() {
|
||||
/// Some(x) => *x = 9,
|
||||
/// Some(x) => *x = 9i,
|
||||
/// None => (),
|
||||
/// }
|
||||
/// assert_eq!(d.back(), Some(&9));
|
||||
/// assert_eq!(d.back(), Some(&9i));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn back_mut(&mut self) -> Option<&mut T> {
|
||||
@ -755,11 +755,11 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut d = RingBuf::new();
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
///
|
||||
/// assert_eq!(d.pop_front(), Some(1));
|
||||
/// assert_eq!(d.pop_front(), Some(2));
|
||||
/// assert_eq!(d.pop_front(), Some(1i));
|
||||
/// assert_eq!(d.pop_front(), Some(2i));
|
||||
/// assert_eq!(d.pop_front(), None);
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -781,9 +781,9 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut d = RingBuf::new();
|
||||
/// d.push_front(1);
|
||||
/// d.push_front(2);
|
||||
/// assert_eq!(d.front(), Some(&2));
|
||||
/// d.push_front(1i);
|
||||
/// d.push_front(2i);
|
||||
/// assert_eq!(d.front(), Some(&2i));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn push_front(&mut self, t: T) {
|
||||
@ -805,7 +805,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(1);
|
||||
/// buf.push_back(1i);
|
||||
/// buf.push_back(3);
|
||||
/// assert_eq!(3, *buf.back().unwrap());
|
||||
/// ```
|
||||
@ -831,7 +831,7 @@ impl<T> RingBuf<T> {
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// assert_eq!(buf.pop_back(), None);
|
||||
/// buf.push_back(1);
|
||||
/// buf.push_back(1i);
|
||||
/// buf.push_back(3);
|
||||
/// assert_eq!(buf.pop_back(), Some(3));
|
||||
/// ```
|
||||
@ -928,7 +928,7 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(10i);
|
||||
/// buf.push_back(12);
|
||||
/// buf.insert(1,11);
|
||||
/// assert_eq!(Some(&11), buf.get(1));
|
||||
@ -1130,9 +1130,9 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(12);
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(10i);
|
||||
/// buf.push_back(12i);
|
||||
/// buf.push_back(15);
|
||||
/// buf.remove(2);
|
||||
/// assert_eq!(Some(&15), buf.get(2));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,13 +25,13 @@
|
||||
//! ```
|
||||
//! let ys: Vec<i32> = vec![];
|
||||
//!
|
||||
//! let zs = vec![1, 2, 3, 4, 5];
|
||||
//! let zs = vec![1i32, 2, 3, 4, 5];
|
||||
//! ```
|
||||
//!
|
||||
//! Push:
|
||||
//!
|
||||
//! ```
|
||||
//! let mut xs = vec![1, 2];
|
||||
//! let mut xs = vec![1i32, 2];
|
||||
//!
|
||||
//! xs.push(3);
|
||||
//! ```
|
||||
@ -39,7 +39,7 @@
|
||||
//! And pop:
|
||||
//!
|
||||
//! ```
|
||||
//! let mut xs = vec![1, 2];
|
||||
//! let mut xs = vec![1i32, 2];
|
||||
//!
|
||||
//! let two = xs.pop();
|
||||
//! ```
|
||||
@ -71,8 +71,8 @@ use core::uint;
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = Vec::new();
|
||||
/// vec.push(1);
|
||||
/// vec.push(2);
|
||||
/// vec.push(1i);
|
||||
/// vec.push(2i);
|
||||
///
|
||||
/// assert_eq!(vec.len(), 2);
|
||||
/// assert_eq!(vec[0], 1);
|
||||
@ -80,7 +80,7 @@ use core::uint;
|
||||
/// assert_eq!(vec.pop(), Some(2));
|
||||
/// assert_eq!(vec.len(), 1);
|
||||
///
|
||||
/// vec[0] = 7;
|
||||
/// vec[0] = 7i;
|
||||
/// assert_eq!(vec[0], 7);
|
||||
///
|
||||
/// vec.push_all(&[1, 2, 3]);
|
||||
@ -88,13 +88,13 @@ use core::uint;
|
||||
/// for x in vec.iter() {
|
||||
/// println!("{}", x);
|
||||
/// }
|
||||
/// assert_eq!(vec, vec![7, 1, 2, 3]);
|
||||
/// assert_eq!(vec, vec![7i, 1, 2, 3]);
|
||||
/// ```
|
||||
///
|
||||
/// The `vec!` macro is provided to make initialization more convenient:
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1, 2, 3];
|
||||
/// let mut vec = vec![1i, 2i, 3i];
|
||||
/// vec.push(4);
|
||||
/// assert_eq!(vec, vec![1, 2, 3, 4]);
|
||||
/// ```
|
||||
@ -104,9 +104,9 @@ use core::uint;
|
||||
/// ```
|
||||
/// let mut stack = Vec::new();
|
||||
///
|
||||
/// stack.push(1);
|
||||
/// stack.push(2);
|
||||
/// stack.push(3);
|
||||
/// stack.push(1i);
|
||||
/// stack.push(2i);
|
||||
/// stack.push(3i);
|
||||
///
|
||||
/// loop {
|
||||
/// let top = match stack.pop() {
|
||||
@ -218,7 +218,7 @@ impl<T> Vec<T> {
|
||||
/// use std::mem;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let mut v = vec![1, 2, 3];
|
||||
/// let mut v = vec![1i, 2, 3];
|
||||
///
|
||||
/// // Pull out the various important pieces of information about `v`
|
||||
/// let p = v.as_mut_ptr();
|
||||
@ -237,7 +237,7 @@ impl<T> Vec<T> {
|
||||
///
|
||||
/// // Put everything back together into a Vec
|
||||
/// let rebuilt = Vec::from_raw_parts(p, len, cap);
|
||||
/// assert_eq!(rebuilt, vec![4, 5, 6]);
|
||||
/// assert_eq!(rebuilt, vec![4i, 5i, 6i]);
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
@ -392,7 +392,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1, 2, 3, 4];
|
||||
/// let mut vec = vec![1i, 2, 3, 4];
|
||||
/// vec.truncate(2);
|
||||
/// assert_eq!(vec, vec![1, 2]);
|
||||
/// ```
|
||||
@ -416,7 +416,7 @@ impl<T> Vec<T> {
|
||||
/// ```
|
||||
/// fn foo(slice: &mut [int]) {}
|
||||
///
|
||||
/// let mut vec = vec![1, 2];
|
||||
/// let mut vec = vec![1i, 2];
|
||||
/// foo(vec.as_mut_slice());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -519,7 +519,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1, 2, 3];
|
||||
/// let mut vec = vec![1i, 2, 3];
|
||||
/// vec.insert(1, 4);
|
||||
/// assert_eq!(vec, vec![1, 4, 2, 3]);
|
||||
/// vec.insert(4, 5);
|
||||
@ -557,7 +557,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut v = vec![1, 2, 3];
|
||||
/// let mut v = vec![1i, 2, 3];
|
||||
/// assert_eq!(v.remove(1), 2);
|
||||
/// assert_eq!(v, vec![1, 3]);
|
||||
/// ```
|
||||
@ -591,7 +591,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1, 2, 3, 4];
|
||||
/// let mut vec = vec![1i, 2, 3, 4];
|
||||
/// vec.retain(|&x| x%2 == 0);
|
||||
/// assert_eq!(vec, vec![2, 4]);
|
||||
/// ```
|
||||
@ -624,7 +624,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// let mut vec = vec!(1, 2);
|
||||
/// let mut vec = vec!(1i, 2);
|
||||
/// vec.push(3);
|
||||
/// assert_eq!(vec, vec!(1, 2, 3));
|
||||
/// ```
|
||||
@ -662,7 +662,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// let mut vec = vec![1, 2, 3];
|
||||
/// let mut vec = vec![1i, 2, 3];
|
||||
/// assert_eq!(vec.pop(), Some(3));
|
||||
/// assert_eq!(vec, vec![1, 2]);
|
||||
/// ```
|
||||
@ -716,7 +716,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut v = vec![1, 2, 3];
|
||||
/// let mut v = vec![1i, 2, 3];
|
||||
///
|
||||
/// v.clear();
|
||||
///
|
||||
@ -733,7 +733,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let a = vec![1, 2, 3];
|
||||
/// let a = vec![1i, 2, 3];
|
||||
/// assert_eq!(a.len(), 3);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -748,7 +748,7 @@ impl<T> Vec<T> {
|
||||
/// let mut v = Vec::new();
|
||||
/// assert!(v.is_empty());
|
||||
///
|
||||
/// v.push(1);
|
||||
/// v.push(1i);
|
||||
/// assert!(!v.is_empty());
|
||||
/// ```
|
||||
#[stable]
|
||||
@ -965,7 +965,7 @@ impl<T: Clone> Vec<T> {
|
||||
/// vec.resize(3, "world");
|
||||
/// assert_eq!(vec, vec!["hello", "world", "world"]);
|
||||
///
|
||||
/// let mut vec = vec![1, 2, 3, 4];
|
||||
/// let mut vec = vec![1i, 2, 3, 4];
|
||||
/// vec.resize(2, 0);
|
||||
/// assert_eq!(vec, vec![1, 2]);
|
||||
/// ```
|
||||
@ -988,8 +988,8 @@ impl<T: Clone> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1];
|
||||
/// vec.push_all(&[2, 3, 4]);
|
||||
/// let mut vec = vec![1i];
|
||||
/// vec.push_all(&[2i, 3, 4]);
|
||||
/// assert_eq!(vec, vec![1, 2, 3, 4]);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -1021,11 +1021,11 @@ impl<T: PartialEq> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1, 2, 2, 3, 2];
|
||||
/// let mut vec = vec![1i, 2, 2, 3, 2];
|
||||
///
|
||||
/// vec.dedup();
|
||||
///
|
||||
/// assert_eq!(vec, vec![1, 2, 3, 2]);
|
||||
/// assert_eq!(vec, vec![1i, 2, 3, 2]);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn dedup(&mut self) {
|
||||
@ -1378,7 +1378,7 @@ impl<T> AsSlice<T> for Vec<T> {
|
||||
/// ```
|
||||
/// fn foo(slice: &[int]) {}
|
||||
///
|
||||
/// let vec = vec![1, 2];
|
||||
/// let vec = vec![1i, 2];
|
||||
/// foo(vec.as_slice());
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -765,7 +765,7 @@ impl<T> AtomicPtr<T> {
|
||||
/// ```
|
||||
/// use std::sync::atomic::AtomicPtr;
|
||||
///
|
||||
/// let ptr = &mut 5;
|
||||
/// let ptr = &mut 5i;
|
||||
/// let atomic_ptr = AtomicPtr::new(ptr);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -787,7 +787,7 @@ impl<T> AtomicPtr<T> {
|
||||
/// ```
|
||||
/// use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
///
|
||||
/// let ptr = &mut 5;
|
||||
/// let ptr = &mut 5i;
|
||||
/// let some_ptr = AtomicPtr::new(ptr);
|
||||
///
|
||||
/// let value = some_ptr.load(Ordering::Relaxed);
|
||||
@ -809,10 +809,10 @@ impl<T> AtomicPtr<T> {
|
||||
/// ```
|
||||
/// use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
///
|
||||
/// let ptr = &mut 5;
|
||||
/// let ptr = &mut 5i;
|
||||
/// let some_ptr = AtomicPtr::new(ptr);
|
||||
///
|
||||
/// let other_ptr = &mut 10;
|
||||
/// let other_ptr = &mut 10i;
|
||||
///
|
||||
/// some_ptr.store(other_ptr, Ordering::Relaxed);
|
||||
/// ```
|
||||
@ -835,10 +835,10 @@ impl<T> AtomicPtr<T> {
|
||||
/// ```
|
||||
/// use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
///
|
||||
/// let ptr = &mut 5;
|
||||
/// let ptr = &mut 5i;
|
||||
/// let some_ptr = AtomicPtr::new(ptr);
|
||||
///
|
||||
/// let other_ptr = &mut 10;
|
||||
/// let other_ptr = &mut 10i;
|
||||
///
|
||||
/// let value = some_ptr.swap(other_ptr, Ordering::Relaxed);
|
||||
/// ```
|
||||
@ -860,11 +860,11 @@ impl<T> AtomicPtr<T> {
|
||||
/// ```
|
||||
/// use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
///
|
||||
/// let ptr = &mut 5;
|
||||
/// let ptr = &mut 5i;
|
||||
/// let some_ptr = AtomicPtr::new(ptr);
|
||||
///
|
||||
/// let other_ptr = &mut 10;
|
||||
/// let another_ptr = &mut 10;
|
||||
/// let other_ptr = &mut 10i;
|
||||
/// let another_ptr = &mut 10i;
|
||||
///
|
||||
/// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed);
|
||||
/// ```
|
||||
|
@ -145,7 +145,7 @@ pub struct RadixFmt<T, R>(T, R);
|
||||
///
|
||||
/// ```
|
||||
/// use std::fmt::radix;
|
||||
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
|
||||
/// assert_eq!(format!("{}", radix(55i, 36)), "1j".to_string());
|
||||
/// ```
|
||||
#[unstable = "may be renamed or move to a different module"]
|
||||
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
|
||||
|
@ -33,7 +33,7 @@
|
||||
//! translated to the `loop` below.
|
||||
//!
|
||||
//! ```rust
|
||||
//! let values = vec![1, 2, 3];
|
||||
//! let values = vec![1i, 2, 3];
|
||||
//!
|
||||
//! // "Syntactical sugar" taking advantage of an iterator
|
||||
//! for &x in values.iter() {
|
||||
@ -176,8 +176,8 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [0];
|
||||
/// let b = [1];
|
||||
/// let a = [0i];
|
||||
/// let b = [1i];
|
||||
/// let mut it = a.iter().chain(b.iter());
|
||||
/// assert_eq!(it.next().unwrap(), &0);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
@ -199,10 +199,10 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [0];
|
||||
/// let b = [1];
|
||||
/// let a = [0i];
|
||||
/// let b = [1i];
|
||||
/// let mut it = a.iter().zip(b.iter());
|
||||
/// let (x0, x1) = (0, 1);
|
||||
/// let (x0, x1) = (0i, 1i);
|
||||
/// assert_eq!(it.next().unwrap(), (&x0, &x1));
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
@ -220,7 +220,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2];
|
||||
/// let a = [1i, 2];
|
||||
/// let mut it = a.iter().map(|&x| 2 * x);
|
||||
/// assert_eq!(it.next().unwrap(), 2);
|
||||
/// assert_eq!(it.next().unwrap(), 4);
|
||||
@ -241,7 +241,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2];
|
||||
/// let a = [1i, 2];
|
||||
/// let mut it = a.iter().filter(|&x| *x > 1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
/// assert!(it.next().is_none());
|
||||
@ -261,7 +261,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2];
|
||||
/// let a = [1i, 2];
|
||||
/// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None});
|
||||
/// assert_eq!(it.next().unwrap(), 4);
|
||||
/// assert!(it.next().is_none());
|
||||
@ -280,9 +280,9 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [100, 200];
|
||||
/// let a = [100i, 200];
|
||||
/// let mut it = a.iter().enumerate();
|
||||
/// let (x100, x200) = (100, 200);
|
||||
/// let (x100, x200) = (100i, 200i);
|
||||
/// assert_eq!(it.next().unwrap(), (0, &x100));
|
||||
/// assert_eq!(it.next().unwrap(), (1, &x200));
|
||||
/// assert!(it.next().is_none());
|
||||
@ -299,7 +299,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let xs = [100, 200, 300];
|
||||
/// let xs = [100i, 200, 300];
|
||||
/// let mut it = xs.iter().map(|x| *x).peekable();
|
||||
/// assert_eq!(*it.peek().unwrap(), 100);
|
||||
/// assert_eq!(it.next().unwrap(), 100);
|
||||
@ -323,7 +323,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 2, 1];
|
||||
/// let a = [1i, 2, 3, 2, 1];
|
||||
/// let mut it = a.iter().skip_while(|&a| *a < 3);
|
||||
/// assert_eq!(it.next().unwrap(), &3);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
@ -345,7 +345,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 2, 1];
|
||||
/// let a = [1i, 2, 3, 2, 1];
|
||||
/// let mut it = a.iter().take_while(|&a| *a < 3);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
@ -365,7 +365,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().skip(3);
|
||||
/// assert_eq!(it.next().unwrap(), &4);
|
||||
/// assert_eq!(it.next().unwrap(), &5);
|
||||
@ -383,7 +383,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().take(3);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
@ -404,7 +404,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().scan(1, |fac, &x| {
|
||||
/// *fac = *fac * x;
|
||||
/// Some(*fac)
|
||||
@ -477,9 +477,9 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// }
|
||||
/// sum
|
||||
/// }
|
||||
/// let x = vec![1,2,3,7,8,9];
|
||||
/// let x = vec![1i,2,3,7,8,9];
|
||||
/// assert_eq!(process(x.into_iter()), 6);
|
||||
/// let x = vec![1,2,3];
|
||||
/// let x = vec![1i,2,3];
|
||||
/// assert_eq!(process(x.into_iter()), 1006);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -540,7 +540,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let b: Vec<int> = a.iter().map(|&x| x).collect();
|
||||
/// assert!(a.as_slice() == b.as_slice());
|
||||
/// ```
|
||||
@ -556,7 +556,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// do not.
|
||||
///
|
||||
/// ```
|
||||
/// let vec = vec![1, 2, 3, 4];
|
||||
/// let vec = vec![1i, 2i, 3i, 4i];
|
||||
/// let (even, odd): (Vec<int>, Vec<int>) = vec.into_iter().partition(|&n| n % 2 == 0);
|
||||
/// assert_eq!(even, vec![2, 4]);
|
||||
/// assert_eq!(odd, vec![1, 3]);
|
||||
@ -586,7 +586,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().fold(0, |a, &b| a + b) == 15);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -606,7 +606,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().all(|x| *x > 0));
|
||||
/// assert!(!a.iter().all(|x| *x > 2));
|
||||
/// ```
|
||||
@ -623,7 +623,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter();
|
||||
/// assert!(it.any(|x| *x == 3));
|
||||
/// assert!(!it.any(|x| *x == 3));
|
||||
@ -812,7 +812,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// ```rust
|
||||
/// use core::num::SignedInt;
|
||||
///
|
||||
/// let xs = [-3, 0, 1, 5, -10];
|
||||
/// let xs = [-3i, 0, 1, 5, -10];
|
||||
/// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -841,7 +841,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
/// ```rust
|
||||
/// use core::num::SignedInt;
|
||||
///
|
||||
/// let xs = [-3, 0, 1, 5, -10];
|
||||
/// let xs = [-3i, 0, 1, 5, -10];
|
||||
/// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -1096,7 +1096,7 @@ pub trait AdditiveIterator<A> {
|
||||
/// ```rust
|
||||
/// use std::iter::AdditiveIterator;
|
||||
///
|
||||
/// let a: [i32] = [1, 2, 3, 4, 5];
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().map(|&x| x);
|
||||
/// assert!(it.sum() == 15);
|
||||
/// ```
|
||||
@ -1171,6 +1171,134 @@ impl_multiplicative! { uint, 1 }
|
||||
impl_multiplicative! { f32, 1.0 }
|
||||
impl_multiplicative! { f64, 1.0 }
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/// A trait for iterators over elements which can be compared to one another.
|
||||
#[unstable = "recently renamed for new extension trait conventions"]
|
||||
pub trait IteratorOrdExt<A> {
|
||||
/// Consumes the entire iterator to return the maximum element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().max().unwrap() == &5);
|
||||
/// ```
|
||||
fn max(self) -> Option<A>;
|
||||
|
||||
/// Consumes the entire iterator to return the minimum element.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().min().unwrap() == &1);
|
||||
/// ```
|
||||
fn min(self) -> Option<A>;
|
||||
|
||||
/// `min_max` finds the minimum and maximum elements in the iterator.
|
||||
///
|
||||
/// The return type `MinMaxResult` is an enum of three variants:
|
||||
///
|
||||
/// - `NoElements` if the iterator is empty.
|
||||
/// - `OneElement(x)` if the iterator has exactly one element.
|
||||
/// - `MinMax(x, y)` is returned otherwise, where `x <= y`. Two
|
||||
/// values are equal if and only if there is more than one
|
||||
/// element in the iterator and all elements are equal.
|
||||
///
|
||||
/// On an iterator of length `n`, `min_max` does `1.5 * n` comparisons,
|
||||
/// and so is faster than calling `min` and `max` separately which does `2 * n` comparisons.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
|
||||
///
|
||||
/// let v: [int; 0] = [];
|
||||
/// assert_eq!(v.iter().min_max(), NoElements);
|
||||
///
|
||||
/// let v = [1i];
|
||||
/// assert!(v.iter().min_max() == OneElement(&1));
|
||||
///
|
||||
/// let v = [1i, 2, 3, 4, 5];
|
||||
/// assert!(v.iter().min_max() == MinMax(&1, &5));
|
||||
///
|
||||
/// let v = [1i, 2, 3, 4, 5, 6];
|
||||
/// assert!(v.iter().min_max() == MinMax(&1, &6));
|
||||
///
|
||||
/// let v = [1i, 1, 1, 1];
|
||||
/// assert!(v.iter().min_max() == MinMax(&1, &1));
|
||||
/// ```
|
||||
fn min_max(self) -> MinMaxResult<A>;
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl<T, I> IteratorOrdExt<T> for I where I: Iterator<Item=T>, T: Ord {
|
||||
#[inline]
|
||||
fn max(self) -> Option<T> {
|
||||
self.fold(None, |max, x| {
|
||||
match max {
|
||||
None => Some(x),
|
||||
Some(y) => Some(cmp::max(x, y))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn min(self) -> Option<T> {
|
||||
self.fold(None, |min, x| {
|
||||
match min {
|
||||
None => Some(x),
|
||||
Some(y) => Some(cmp::min(x, y))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn min_max(mut self) -> MinMaxResult<T> {
|
||||
let (mut min, mut max) = match self.next() {
|
||||
None => return NoElements,
|
||||
Some(x) => {
|
||||
match self.next() {
|
||||
None => return OneElement(x),
|
||||
Some(y) => if x < y {(x, y)} else {(y,x)}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
loop {
|
||||
// `first` and `second` are the two next elements we want to look at.
|
||||
// We first compare `first` and `second` (#1). The smaller one is then compared to
|
||||
// current minimum (#2). The larger one is compared to current maximum (#3). This
|
||||
// way we do 3 comparisons for 2 elements.
|
||||
let first = match self.next() {
|
||||
None => break,
|
||||
Some(x) => x
|
||||
};
|
||||
let second = match self.next() {
|
||||
None => {
|
||||
if first < min {
|
||||
min = first;
|
||||
} else if first > max {
|
||||
max = first;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Some(x) => x
|
||||
};
|
||||
if first < second {
|
||||
if first < min {min = first;}
|
||||
if max < second {max = second;}
|
||||
} else {
|
||||
if second < min {min = second;}
|
||||
if max < first {max = first;}
|
||||
}
|
||||
}
|
||||
|
||||
MinMax(min, max)
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> parent of f031671... Remove i suffix in docs
|
||||
/// `MinMaxResult` is an enum returned by `min_max`. See `IteratorOrdExt::min_max` for more detail.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[unstable = "unclear whether such a fine-grained result is widely useful"]
|
||||
@ -1199,10 +1327,10 @@ impl<T: Clone> MinMaxResult<T> {
|
||||
/// let r: MinMaxResult<int> = NoElements;
|
||||
/// assert_eq!(r.into_option(), None);
|
||||
///
|
||||
/// let r = OneElement(1);
|
||||
/// let r = OneElement(1i);
|
||||
/// assert_eq!(r.into_option(), Some((1,1)));
|
||||
///
|
||||
/// let r = MinMax(1, 2);
|
||||
/// let r = MinMax(1i,2i);
|
||||
/// assert_eq!(r.into_option(), Some((1,2)));
|
||||
/// ```
|
||||
#[unstable = "type is unstable"]
|
||||
@ -1258,6 +1386,35 @@ impl<T, D, I> ExactSizeIterator for Cloned<I> where
|
||||
I: ExactSizeIterator + Iterator<Item=D>,
|
||||
{}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#[unstable = "recently renamed for extension trait conventions"]
|
||||
/// An extension trait for cloneable iterators.
|
||||
pub trait CloneIteratorExt {
|
||||
/// Repeats an iterator endlessly
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::iter::{CloneIteratorExt, count};
|
||||
///
|
||||
/// let a = count(1i,1i).take(1);
|
||||
/// let mut cy = a.cycle();
|
||||
/// assert_eq!(cy.next(), Some(1));
|
||||
/// assert_eq!(cy.next(), Some(1));
|
||||
/// ```
|
||||
#[stable]
|
||||
fn cycle(self) -> Cycle<Self>;
|
||||
}
|
||||
|
||||
impl<I> CloneIteratorExt for I where I: Iterator + Clone {
|
||||
#[inline]
|
||||
fn cycle(self) -> Cycle<I> {
|
||||
Cycle{orig: self.clone(), iter: self}
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> parent of f031671... Remove i suffix in docs
|
||||
/// An iterator that repeats endlessly
|
||||
#[derive(Clone, Copy)]
|
||||
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
|
||||
|
@ -187,13 +187,13 @@ pub unsafe fn uninitialized<T>() -> T {
|
||||
/// ```
|
||||
/// use std::mem;
|
||||
///
|
||||
/// let x = &mut 5;
|
||||
/// let y = &mut 42;
|
||||
/// let x = &mut 5i;
|
||||
/// let y = &mut 42i;
|
||||
///
|
||||
/// mem::swap(x, y);
|
||||
///
|
||||
/// assert_eq!(42, *x);
|
||||
/// assert_eq!(5, *y);
|
||||
/// assert_eq!(42i, *x);
|
||||
/// assert_eq!(5i, *y);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable]
|
||||
|
@ -336,7 +336,7 @@ pub trait Int
|
||||
/// ```rust
|
||||
/// use std::num::Int;
|
||||
///
|
||||
/// assert_eq!(2.pow(4), 16);
|
||||
/// assert_eq!(2i.pow(4), 16);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn pow(self, mut exp: uint) -> Self {
|
||||
|
@ -470,10 +470,10 @@ impl<T> Option<T> {
|
||||
///
|
||||
/// ```
|
||||
/// let x = Some("foo");
|
||||
/// assert_eq!(x.ok_or(0), Ok("foo"));
|
||||
/// assert_eq!(x.ok_or(0i), Ok("foo"));
|
||||
///
|
||||
/// let x: Option<&str> = None;
|
||||
/// assert_eq!(x.ok_or(0), Err(0));
|
||||
/// assert_eq!(x.ok_or(0i), Err(0i));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[experimental]
|
||||
@ -491,10 +491,10 @@ impl<T> Option<T> {
|
||||
///
|
||||
/// ```
|
||||
/// let x = Some("foo");
|
||||
/// assert_eq!(x.ok_or_else(|| 0), Ok("foo"));
|
||||
/// assert_eq!(x.ok_or_else(|| 0i), Ok("foo"));
|
||||
///
|
||||
/// let x: Option<&str> = None;
|
||||
/// assert_eq!(x.ok_or_else(|| 0), Err(0));
|
||||
/// assert_eq!(x.ok_or_else(|| 0i), Err(0i));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[experimental]
|
||||
@ -728,8 +728,8 @@ impl<T: Default> Option<T> {
|
||||
/// let good_year = good_year_from_input.parse().unwrap_or_default();
|
||||
/// let bad_year = bad_year_from_input.parse().unwrap_or_default();
|
||||
///
|
||||
/// assert_eq!(1909, good_year);
|
||||
/// assert_eq!(0, bad_year);
|
||||
/// assert_eq!(1909i, good_year);
|
||||
/// assert_eq!(0i, bad_year);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable]
|
||||
|
@ -119,7 +119,7 @@ macro_rules! warn {
|
||||
/// #[macro_use] extern crate log;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let ret = 3;
|
||||
/// let ret = 3i;
|
||||
/// info!("this function is about to return: {}", ret);
|
||||
/// }
|
||||
/// ```
|
||||
@ -145,7 +145,7 @@ macro_rules! info {
|
||||
/// #[macro_use] extern crate log;
|
||||
///
|
||||
/// fn main() {
|
||||
/// debug!("x = {x}, y = {y}", x=10, y=20);
|
||||
/// debug!("x = {x}, y = {y}", x=10i, y=20i);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -287,7 +287,7 @@ pub trait Rng : Sized {
|
||||
/// ```
|
||||
/// use std::rand::{thread_rng, Rng};
|
||||
///
|
||||
/// let choices = [1, 2, 4, 8, 16, 32];
|
||||
/// let choices = [1i, 2, 4, 8, 16, 32];
|
||||
/// let mut rng = thread_rng();
|
||||
/// println!("{}", rng.choose(&choices));
|
||||
/// # // replace with slicing syntax when it's stable!
|
||||
@ -309,7 +309,7 @@ pub trait Rng : Sized {
|
||||
/// use std::rand::{thread_rng, Rng};
|
||||
///
|
||||
/// let mut rng = thread_rng();
|
||||
/// let mut y = [1, 2, 3];
|
||||
/// let mut y = [1i, 2, 3];
|
||||
/// rng.shuffle(&mut y);
|
||||
/// println!("{}", y.as_slice());
|
||||
/// rng.shuffle(&mut y);
|
||||
|
@ -166,7 +166,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
///
|
||||
/// let h = SipHasher::new();
|
||||
/// let mut set = HashSet::with_capacity_and_hasher(10u, h);
|
||||
/// set.insert(1);
|
||||
/// set.insert(1i);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable = "hasher stuff is unclear"]
|
||||
@ -285,8 +285,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
///
|
||||
/// // Can be seen as `a - b`.
|
||||
/// for x in a.difference(&b) {
|
||||
@ -294,12 +294,12 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
/// }
|
||||
///
|
||||
/// let diff: HashSet<int> = a.difference(&b).map(|&x| x).collect();
|
||||
/// assert_eq!(diff, [1].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [1i].iter().map(|&x| x).collect());
|
||||
///
|
||||
/// // Note that difference is not symmetric,
|
||||
/// // and `b - a` means something else:
|
||||
/// let diff: HashSet<int> = b.difference(&a).map(|&x| x).collect();
|
||||
/// assert_eq!(diff, [4].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [4i].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn difference<'a>(&'a self, other: &'a HashSet<T, H>) -> Difference<'a, T, H> {
|
||||
@ -315,8 +315,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
///
|
||||
/// // Print 1, 4 in arbitrary order.
|
||||
/// for x in a.symmetric_difference(&b) {
|
||||
@ -327,7 +327,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
/// let diff2: HashSet<int> = b.symmetric_difference(&a).map(|&x| x).collect();
|
||||
///
|
||||
/// assert_eq!(diff1, diff2);
|
||||
/// assert_eq!(diff1, [1, 4].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff1, [1i, 4].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, H>)
|
||||
@ -341,8 +341,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
///
|
||||
/// // Print 2, 3 in arbitrary order.
|
||||
/// for x in a.intersection(&b) {
|
||||
@ -350,7 +350,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
/// }
|
||||
///
|
||||
/// let diff: HashSet<int> = a.intersection(&b).map(|&x| x).collect();
|
||||
/// assert_eq!(diff, [2, 3].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [2i, 3].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, H>) -> Intersection<'a, T, H> {
|
||||
@ -366,8 +366,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
|
||||
///
|
||||
/// // Print 1, 2, 3, 4 in arbitrary order.
|
||||
/// for x in a.union(&b) {
|
||||
@ -375,7 +375,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
||||
/// }
|
||||
///
|
||||
/// let diff: HashSet<int> = a.union(&b).map(|&x| x).collect();
|
||||
/// assert_eq!(diff, [1, 2, 3, 4].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [1i, 2, 3, 4].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn union<'a>(&'a self, other: &'a HashSet<T, H>) -> Union<'a, T, H> {
|
||||
|
@ -32,7 +32,7 @@
|
||||
/// # #![allow(unreachable_code)]
|
||||
/// panic!();
|
||||
/// panic!("this is a terrible mistake!");
|
||||
/// panic!(4); // panic with the value of 4 to be collected elsewhere
|
||||
/// panic!(4i); // panic with the value of 4 to be collected elsewhere
|
||||
/// panic!("this is a {} {message}", "fancy", message = "message");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
@ -73,7 +73,7 @@ macro_rules! panic {
|
||||
/// // assert with a custom message
|
||||
/// # let x = true;
|
||||
/// assert!(x, "x wasn't true!");
|
||||
/// # let a = 3; let b = 27;
|
||||
/// # let a = 3i; let b = 27i;
|
||||
/// assert!(a + b == 30, "a = {}, b = {}", a, b);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
@ -98,8 +98,8 @@ macro_rules! assert {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// let a = 3;
|
||||
/// let b = 1 + 2;
|
||||
/// let a = 3i;
|
||||
/// let b = 1i + 2i;
|
||||
/// assert_eq!(a, b);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
@ -140,7 +140,7 @@ macro_rules! assert_eq {
|
||||
/// // assert with a custom message
|
||||
/// # let x = true;
|
||||
/// debug_assert!(x, "x wasn't true!");
|
||||
/// # let a = 3; let b = 27;
|
||||
/// # let a = 3i; let b = 27i;
|
||||
/// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
@ -161,8 +161,8 @@ macro_rules! debug_assert {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// let a = 3;
|
||||
/// let b = 1 + 2;
|
||||
/// let a = 3i;
|
||||
/// let b = 1i + 2i;
|
||||
/// debug_assert_eq!(a, b);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
@ -237,7 +237,7 @@ macro_rules! unimplemented {
|
||||
/// ```
|
||||
/// format!("test");
|
||||
/// format!("hello {}", "world!");
|
||||
/// format!("x = {}, y = {y}", 10, y = 30);
|
||||
/// format!("x = {}, y = {y}", 10i, y = 30i);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
#[stable]
|
||||
@ -301,7 +301,7 @@ macro_rules! try {
|
||||
/// let (tx1, rx1) = channel();
|
||||
/// let (tx2, rx2) = channel();
|
||||
/// # fn long_running_task() {}
|
||||
/// # fn calculate_the_answer() -> int { 42 }
|
||||
/// # fn calculate_the_answer() -> int { 42i }
|
||||
///
|
||||
/// Thread::spawn(move|| { long_running_task(); tx1.send(()) }).detach();
|
||||
/// Thread::spawn(move|| { tx2.send(calculate_the_answer()) }).detach();
|
||||
@ -470,7 +470,7 @@ pub mod builtin {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// let s = concat!("test", 10, 'b', true);
|
||||
/// let s = concat!("test", 10i, 'b', true);
|
||||
/// assert_eq!(s, "test10btrue");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ use sys_common::rwlock as sys;
|
||||
/// ```
|
||||
/// use std::sync::RwLock;
|
||||
///
|
||||
/// let lock = RwLock::new(5);
|
||||
/// let lock = RwLock::new(5i);
|
||||
///
|
||||
/// // many reader locks can be held at once
|
||||
/// {
|
||||
|
Loading…
Reference in New Issue
Block a user