rollup merge of #20434: steveklabnik/five_eye
This takes advantage of integer fallback to stop recomending `i` so much.
This commit is contained in:
commit
059566b019
20 changed files with 1413 additions and 1315 deletions
|
@ -35,7 +35,7 @@
|
|||
//! use std::sync::Arc;
|
||||
//! use std::thread::Thread;
|
||||
//!
|
||||
//! let five = Arc::new(5i);
|
||||
//! let five = Arc::new(5);
|
||||
//!
|
||||
//! 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(5i));
|
||||
//! let five = Arc::new(Mutex::new(5));
|
||||
//!
|
||||
//! 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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable]
|
||||
|
@ -176,7 +176,7 @@ impl<T> Arc<T> {
|
|||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
/// ```
|
||||
|
@ -220,7 +220,7 @@ impl<T> Clone for Arc<T> {
|
|||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five.clone();
|
||||
/// ```
|
||||
|
@ -267,7 +267,7 @@ impl<T: Send + Sync + Clone> Arc<T> {
|
|||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let mut five = Arc::new(5i);
|
||||
/// let mut five = Arc::new(5);
|
||||
///
|
||||
/// 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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
/// drop(five); // explict drop
|
||||
/// }
|
||||
/// {
|
||||
/// let five = Arc::new(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
|
@ -369,7 +369,7 @@ impl<T: Sync + Send> Weak<T> {
|
|||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// 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(5i).downgrade();
|
||||
/// let weak_five = Arc::new(5).downgrade();
|
||||
///
|
||||
/// weak_five.clone();
|
||||
/// ```
|
||||
|
@ -430,7 +430,7 @@ impl<T: Sync + Send> Drop for Weak<T> {
|
|||
/// use std::sync::Arc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Arc::new(5i);
|
||||
/// let five = Arc::new(5);
|
||||
/// 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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
/// 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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five == Arc::new(5i);
|
||||
/// five == Arc::new(5);
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five != Arc::new(5i);
|
||||
/// five != Arc::new(5);
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five.partial_cmp(&Arc::new(5i));
|
||||
/// five.partial_cmp(&Arc::new(5));
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five < Arc::new(5i);
|
||||
/// five < Arc::new(5);
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five <= Arc::new(5i);
|
||||
/// five <= Arc::new(5);
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five > Arc::new(5i);
|
||||
/// five > Arc::new(5);
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five >= Arc::new(5i);
|
||||
/// five >= Arc::new(5);
|
||||
/// ```
|
||||
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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn new(value: T) -> Rc<T> {
|
||||
|
@ -214,7 +214,7 @@ impl<T> Rc<T> {
|
|||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// 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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// rc::is_unique(&five);
|
||||
/// ```
|
||||
|
@ -329,7 +329,7 @@ impl<T: Clone> Rc<T> {
|
|||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let mut five = Rc::new(5i);
|
||||
/// let mut five = Rc::new(5);
|
||||
///
|
||||
/// let mut_five = five.make_unique();
|
||||
/// ```
|
||||
|
@ -378,14 +378,14 @@ impl<T> Drop for Rc<T> {
|
|||
/// use std::rc::Rc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
/// drop(five); // explict drop
|
||||
/// }
|
||||
/// {
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// // stuff
|
||||
///
|
||||
|
@ -424,7 +424,7 @@ impl<T> Clone for Rc<T> {
|
|||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five.clone();
|
||||
/// ```
|
||||
|
@ -465,9 +465,9 @@ impl<T: PartialEq> PartialEq for Rc<T> {
|
|||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five == Rc::new(5i);
|
||||
/// five == Rc::new(5);
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five != Rc::new(5i);
|
||||
/// five != Rc::new(5);
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five.partial_cmp(&Rc::new(5i));
|
||||
/// five.partial_cmp(&Rc::new(5));
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five < Rc::new(5i);
|
||||
/// five < Rc::new(5);
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five <= Rc::new(5i);
|
||||
/// five <= Rc::new(5);
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five > Rc::new(5i);
|
||||
/// five > Rc::new(5);
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five >= Rc::new(5i);
|
||||
/// five >= Rc::new(5);
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five.partial_cmp(&Rc::new(5i));
|
||||
/// five.partial_cmp(&Rc::new(5));
|
||||
/// ```
|
||||
#[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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
|
@ -668,7 +668,7 @@ impl<T> Drop for Weak<T> {
|
|||
/// use std::rc::Rc;
|
||||
///
|
||||
/// {
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
/// 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(5i);
|
||||
/// let five = Rc::new(5);
|
||||
/// 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(5i).downgrade();
|
||||
/// let weak_five = Rc::new(5).downgrade();
|
||||
///
|
||||
/// weak_five.clone();
|
||||
/// ```
|
||||
|
|
|
@ -211,7 +211,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![9i, 1, 2, 7, 3, 2]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
|
||||
/// ```
|
||||
pub fn from_vec(vec: Vec<T>) -> BinaryHeap<T> {
|
||||
let mut heap = BinaryHeap { data: vec };
|
||||
|
@ -230,7 +230,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![1i, 2, 3, 4]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
|
||||
///
|
||||
/// // Print 1, 2, 3, 4 in arbitrary order
|
||||
/// for x in heap.iter() {
|
||||
|
@ -250,7 +250,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![1i, 2, 3, 4]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
|
||||
///
|
||||
/// // Print 1, 2, 3, 4 in arbitrary order
|
||||
/// for x in heap.into_iter() {
|
||||
|
@ -272,7 +272,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
/// let mut heap = BinaryHeap::new();
|
||||
/// assert_eq!(heap.peek(), None);
|
||||
///
|
||||
/// heap.push(1i);
|
||||
/// heap.push(1);
|
||||
/// heap.push(5);
|
||||
/// heap.push(2);
|
||||
/// assert_eq!(heap.peek(), Some(&5));
|
||||
|
@ -355,7 +355,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1i, 3]);
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
|
||||
///
|
||||
/// assert_eq!(heap.pop(), Some(3));
|
||||
/// assert_eq!(heap.pop(), Some(1));
|
||||
|
@ -379,7 +379,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
/// heap.push(3i);
|
||||
/// heap.push(3);
|
||||
/// heap.push(5);
|
||||
/// heap.push(1);
|
||||
///
|
||||
|
@ -401,7 +401,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
/// heap.push(1i);
|
||||
/// heap.push(1);
|
||||
/// heap.push(5);
|
||||
///
|
||||
/// assert_eq!(heap.push_pop(3), 5);
|
||||
|
@ -433,7 +433,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
/// use std::collections::BinaryHeap;
|
||||
/// let mut heap = BinaryHeap::new();
|
||||
///
|
||||
/// assert_eq!(heap.replace(1i), None);
|
||||
/// assert_eq!(heap.replace(1), None);
|
||||
/// assert_eq!(heap.replace(3), Some(1));
|
||||
/// assert_eq!(heap.len(), 1);
|
||||
/// assert_eq!(heap.peek(), Some(&3));
|
||||
|
@ -456,7 +456,7 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
/// let heap = BinaryHeap::from_vec(vec![1i, 2, 3, 4, 5, 6, 7]);
|
||||
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
|
||||
/// let vec = heap.into_vec();
|
||||
///
|
||||
/// // Will print in some order
|
||||
|
@ -474,12 +474,12 @@ impl<T: Ord> BinaryHeap<T> {
|
|||
/// ```
|
||||
/// use std::collections::BinaryHeap;
|
||||
///
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1i, 2, 4, 5, 7]);
|
||||
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]);
|
||||
/// heap.push(6);
|
||||
/// heap.push(3);
|
||||
///
|
||||
/// let vec = heap.into_sorted_vec();
|
||||
/// assert_eq!(vec, vec![1i, 2, 3, 4, 5, 6, 7]);
|
||||
/// assert_eq!(vec, vec![1, 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(1i);
|
||||
/// v.insert(1);
|
||||
/// 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(1i);
|
||||
/// v.insert(1);
|
||||
/// 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(1i);
|
||||
/// v.insert(1);
|
||||
/// v.clear();
|
||||
/// assert!(v.is_empty());
|
||||
/// ```
|
||||
|
@ -294,7 +294,7 @@ impl<T: Ord> BTreeSet<T> {
|
|||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let set: BTreeSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let set: BTreeSet<int> = [1, 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> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let a: BTreeSet<int> = [1, 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> = [1i, 2, 3].iter().map(|&x| x).collect();
|
||||
/// let sup: BTreeSet<int> = [1, 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> = [1i, 2].iter().map(|&x| x).collect();
|
||||
/// let sub: BTreeSet<int> = [1, 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(2i), true);
|
||||
/// assert_eq!(set.insert(2i), false);
|
||||
/// assert_eq!(set.insert(2), true);
|
||||
/// assert_eq!(set.insert(2), false);
|
||||
/// assert_eq!(set.len(), 1);
|
||||
/// ```
|
||||
#[stable]
|
||||
|
@ -424,7 +424,7 @@ impl<T: Ord> BTreeSet<T> {
|
|||
///
|
||||
/// let mut set = BTreeSet::new();
|
||||
///
|
||||
/// set.insert(2i);
|
||||
/// set.insert(2);
|
||||
/// assert_eq!(set.remove(&2), true);
|
||||
/// assert_eq!(set.remove(&2), false);
|
||||
/// ```
|
||||
|
|
|
@ -230,9 +230,9 @@ impl<T> DList<T> {
|
|||
///
|
||||
/// let mut a = DList::new();
|
||||
/// let mut b = DList::new();
|
||||
/// a.push_back(1i);
|
||||
/// a.push_back(1);
|
||||
/// a.push_back(2);
|
||||
/// b.push_back(3i);
|
||||
/// b.push_back(3);
|
||||
/// b.push_back(4);
|
||||
///
|
||||
/// a.append(b);
|
||||
|
@ -375,7 +375,7 @@ impl<T> DList<T> {
|
|||
/// use std::collections::DList;
|
||||
///
|
||||
/// let mut d = DList::new();
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(3);
|
||||
/// assert_eq!(3, *d.back().unwrap());
|
||||
/// ```
|
||||
|
@ -394,7 +394,7 @@ impl<T> DList<T> {
|
|||
///
|
||||
/// let mut d = DList::new();
|
||||
/// assert_eq!(d.pop_back(), None);
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(3);
|
||||
/// assert_eq!(d.pop_back(), Some(3));
|
||||
/// ```
|
||||
|
@ -551,7 +551,7 @@ impl<'a, A> IterMut<'a, A> {
|
|||
/// }
|
||||
/// {
|
||||
/// let vec: Vec<int> = list.into_iter().collect();
|
||||
/// assert_eq!(vec, vec![1i, 2, 3, 4]);
|
||||
/// assert_eq!(vec, vec![1, 2, 3, 4]);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
|
|
|
@ -184,7 +184,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(3i);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// buf.push_back(5);
|
||||
/// assert_eq!(buf.get(1).unwrap(), &4);
|
||||
|
@ -207,7 +207,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(3i);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// buf.push_back(5);
|
||||
/// match buf.get_mut(1) {
|
||||
|
@ -241,7 +241,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(3i);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// buf.push_back(5);
|
||||
/// buf.swap(0, 2);
|
||||
|
@ -493,7 +493,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// let b: &[_] = &[&5, &3, &4];
|
||||
|
@ -516,7 +516,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(3);
|
||||
/// buf.push_back(4);
|
||||
/// for num in buf.iter_mut() {
|
||||
|
@ -595,7 +595,7 @@ impl<T> RingBuf<T> {
|
|||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// assert_eq!(v.len(), 0);
|
||||
/// v.push_back(1i);
|
||||
/// v.push_back(1);
|
||||
/// assert_eq!(v.len(), 1);
|
||||
/// ```
|
||||
#[stable]
|
||||
|
@ -610,7 +610,7 @@ impl<T> RingBuf<T> {
|
|||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// assert!(v.is_empty());
|
||||
/// v.push_front(1i);
|
||||
/// v.push_front(1);
|
||||
/// assert!(!v.is_empty());
|
||||
/// ```
|
||||
#[stable]
|
||||
|
@ -625,7 +625,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// v.push_back(1i);
|
||||
/// v.push_back(1);
|
||||
/// assert_eq!(v.drain().next(), Some(1));
|
||||
/// assert!(v.is_empty());
|
||||
/// ```
|
||||
|
@ -645,7 +645,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut v = RingBuf::new();
|
||||
/// v.push_back(1i);
|
||||
/// v.push_back(1);
|
||||
/// v.clear();
|
||||
/// assert!(v.is_empty());
|
||||
/// ```
|
||||
|
@ -666,9 +666,9 @@ impl<T> RingBuf<T> {
|
|||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.front(), None);
|
||||
///
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// assert_eq!(d.front(), Some(&1i));
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// assert_eq!(d.front(), Some(&1));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn front(&self) -> Option<&T> {
|
||||
|
@ -686,13 +686,13 @@ impl<T> RingBuf<T> {
|
|||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.front_mut(), None);
|
||||
///
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// match d.front_mut() {
|
||||
/// Some(x) => *x = 9i,
|
||||
/// Some(x) => *x = 9,
|
||||
/// None => (),
|
||||
/// }
|
||||
/// assert_eq!(d.front(), Some(&9i));
|
||||
/// assert_eq!(d.front(), Some(&9));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn front_mut(&mut self) -> Option<&mut T> {
|
||||
|
@ -710,9 +710,9 @@ impl<T> RingBuf<T> {
|
|||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.back(), None);
|
||||
///
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// assert_eq!(d.back(), Some(&2i));
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// assert_eq!(d.back(), Some(&2));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn back(&self) -> Option<&T> {
|
||||
|
@ -730,13 +730,13 @@ impl<T> RingBuf<T> {
|
|||
/// let mut d = RingBuf::new();
|
||||
/// assert_eq!(d.back(), None);
|
||||
///
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
/// match d.back_mut() {
|
||||
/// Some(x) => *x = 9i,
|
||||
/// Some(x) => *x = 9,
|
||||
/// None => (),
|
||||
/// }
|
||||
/// assert_eq!(d.back(), Some(&9i));
|
||||
/// assert_eq!(d.back(), Some(&9));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn back_mut(&mut self) -> Option<&mut T> {
|
||||
|
@ -753,11 +753,11 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut d = RingBuf::new();
|
||||
/// d.push_back(1i);
|
||||
/// d.push_back(2i);
|
||||
/// d.push_back(1);
|
||||
/// d.push_back(2);
|
||||
///
|
||||
/// assert_eq!(d.pop_front(), Some(1i));
|
||||
/// assert_eq!(d.pop_front(), Some(2i));
|
||||
/// assert_eq!(d.pop_front(), Some(1));
|
||||
/// assert_eq!(d.pop_front(), Some(2));
|
||||
/// assert_eq!(d.pop_front(), None);
|
||||
/// ```
|
||||
#[stable]
|
||||
|
@ -779,9 +779,9 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut d = RingBuf::new();
|
||||
/// d.push_front(1i);
|
||||
/// d.push_front(2i);
|
||||
/// assert_eq!(d.front(), Some(&2i));
|
||||
/// d.push_front(1);
|
||||
/// d.push_front(2);
|
||||
/// assert_eq!(d.front(), Some(&2));
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn push_front(&mut self, t: T) {
|
||||
|
@ -803,7 +803,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(1i);
|
||||
/// buf.push_back(1);
|
||||
/// buf.push_back(3);
|
||||
/// assert_eq!(3, *buf.back().unwrap());
|
||||
/// ```
|
||||
|
@ -829,7 +829,7 @@ impl<T> RingBuf<T> {
|
|||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// assert_eq!(buf.pop_back(), None);
|
||||
/// buf.push_back(1i);
|
||||
/// buf.push_back(1);
|
||||
/// buf.push_back(3);
|
||||
/// assert_eq!(buf.pop_back(), Some(3));
|
||||
/// ```
|
||||
|
@ -926,7 +926,7 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(10i);
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(12);
|
||||
/// buf.insert(1,11);
|
||||
/// assert_eq!(Some(&11), buf.get(1));
|
||||
|
@ -1128,9 +1128,9 @@ impl<T> RingBuf<T> {
|
|||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(10i);
|
||||
/// buf.push_back(12i);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(12);
|
||||
/// 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![1i32, 2, 3, 4, 5];
|
||||
//! let zs = vec![1, 2, 3, 4, 5];
|
||||
//! ```
|
||||
//!
|
||||
//! Push:
|
||||
//!
|
||||
//! ```
|
||||
//! let mut xs = vec![1i32, 2];
|
||||
//! let mut xs = vec![1, 2];
|
||||
//!
|
||||
//! xs.push(3);
|
||||
//! ```
|
||||
|
@ -39,7 +39,7 @@
|
|||
//! And pop:
|
||||
//!
|
||||
//! ```
|
||||
//! let mut xs = vec![1i32, 2];
|
||||
//! let mut xs = vec![1, 2];
|
||||
//!
|
||||
//! let two = xs.pop();
|
||||
//! ```
|
||||
|
@ -71,8 +71,8 @@ use core::uint;
|
|||
///
|
||||
/// ```
|
||||
/// let mut vec = Vec::new();
|
||||
/// vec.push(1i);
|
||||
/// vec.push(2i);
|
||||
/// vec.push(1);
|
||||
/// vec.push(2);
|
||||
///
|
||||
/// 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] = 7i;
|
||||
/// vec[0] = 7;
|
||||
/// 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![7i, 1, 2, 3]);
|
||||
/// assert_eq!(vec, vec![7, 1, 2, 3]);
|
||||
/// ```
|
||||
///
|
||||
/// The `vec!` macro is provided to make initialization more convenient:
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1i, 2i, 3i];
|
||||
/// let mut vec = vec![1, 2, 3];
|
||||
/// 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(1i);
|
||||
/// stack.push(2i);
|
||||
/// stack.push(3i);
|
||||
/// stack.push(1);
|
||||
/// stack.push(2);
|
||||
/// stack.push(3);
|
||||
///
|
||||
/// loop {
|
||||
/// let top = match stack.pop() {
|
||||
|
@ -218,7 +218,7 @@ impl<T> Vec<T> {
|
|||
/// use std::mem;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let mut v = vec![1i, 2, 3];
|
||||
/// let mut v = vec![1, 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![4i, 5i, 6i]);
|
||||
/// assert_eq!(rebuilt, vec![4, 5, 6]);
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
|
@ -392,7 +392,7 @@ impl<T> Vec<T> {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1i, 2, 3, 4];
|
||||
/// let mut vec = vec![1, 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![1i, 2];
|
||||
/// let mut vec = vec![1, 2];
|
||||
/// foo(vec.as_mut_slice());
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -519,7 +519,7 @@ impl<T> Vec<T> {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1i, 2, 3];
|
||||
/// let mut vec = vec![1, 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![1i, 2, 3];
|
||||
/// let mut v = vec![1, 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![1i, 2, 3, 4];
|
||||
/// let mut vec = vec![1, 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!(1i, 2);
|
||||
/// let mut vec = vec!(1, 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![1i, 2, 3];
|
||||
/// let mut vec = vec![1, 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![1i, 2, 3];
|
||||
/// let mut v = vec![1, 2, 3];
|
||||
///
|
||||
/// v.clear();
|
||||
///
|
||||
|
@ -733,7 +733,7 @@ impl<T> Vec<T> {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let a = vec![1i, 2, 3];
|
||||
/// let a = vec![1, 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(1i);
|
||||
/// v.push(1);
|
||||
/// 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![1i, 2, 3, 4];
|
||||
/// let mut vec = vec![1, 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![1i];
|
||||
/// vec.push_all(&[2i, 3, 4]);
|
||||
/// let mut vec = vec![1];
|
||||
/// vec.push_all(&[2, 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![1i, 2, 2, 3, 2];
|
||||
/// let mut vec = vec![1, 2, 2, 3, 2];
|
||||
///
|
||||
/// vec.dedup();
|
||||
///
|
||||
/// assert_eq!(vec, vec![1i, 2, 3, 2]);
|
||||
/// assert_eq!(vec, vec![1, 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![1i, 2];
|
||||
/// let vec = vec![1, 2];
|
||||
/// foo(vec.as_slice());
|
||||
/// ```
|
||||
#[inline]
|
||||
|
|
|
@ -793,7 +793,7 @@ impl<T> AtomicPtr<T> {
|
|||
/// ```
|
||||
/// use std::sync::atomic::AtomicPtr;
|
||||
///
|
||||
/// let ptr = &mut 5i;
|
||||
/// let ptr = &mut 5;
|
||||
/// let atomic_ptr = AtomicPtr::new(ptr);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -815,7 +815,7 @@ impl<T> AtomicPtr<T> {
|
|||
/// ```
|
||||
/// 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);
|
||||
|
@ -837,10 +837,10 @@ impl<T> AtomicPtr<T> {
|
|||
/// ```
|
||||
/// 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);
|
||||
/// ```
|
||||
|
@ -863,10 +863,10 @@ impl<T> AtomicPtr<T> {
|
|||
/// ```
|
||||
/// 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);
|
||||
/// ```
|
||||
|
@ -888,11 +888,11 @@ impl<T> AtomicPtr<T> {
|
|||
/// ```
|
||||
/// 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);
|
||||
/// ```
|
||||
|
|
|
@ -145,7 +145,7 @@ pub struct RadixFmt<T, R>(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<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
//! translated to the `loop` below.
|
||||
//!
|
||||
//! ```rust
|
||||
//! let values = vec![1i, 2, 3];
|
||||
//! let values = vec![1, 2, 3];
|
||||
//!
|
||||
//! // "Syntactical sugar" taking advantage of an iterator
|
||||
//! for &x in values.iter() {
|
||||
|
@ -118,8 +118,8 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [0i];
|
||||
/// let b = [1i];
|
||||
/// let a = [0];
|
||||
/// let b = [1];
|
||||
/// let mut it = a.iter().chain(b.iter());
|
||||
/// assert_eq!(it.next().unwrap(), &0);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
|
@ -141,10 +141,10 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [0i];
|
||||
/// let b = [1i];
|
||||
/// let a = [0];
|
||||
/// let b = [1];
|
||||
/// let mut it = a.iter().zip(b.iter());
|
||||
/// let (x0, x1) = (0i, 1i);
|
||||
/// let (x0, x1) = (0, 1);
|
||||
/// assert_eq!(it.next().unwrap(), (&x0, &x1));
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
|
@ -162,7 +162,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2];
|
||||
/// let a = [1, 2];
|
||||
/// let mut it = a.iter().map(|&x| 2 * x);
|
||||
/// assert_eq!(it.next().unwrap(), 2);
|
||||
/// assert_eq!(it.next().unwrap(), 4);
|
||||
|
@ -183,7 +183,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2];
|
||||
/// let a = [1, 2];
|
||||
/// let mut it = a.iter().filter(|&x| *x > 1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
/// assert!(it.next().is_none());
|
||||
|
@ -203,7 +203,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2];
|
||||
/// let a = [1, 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());
|
||||
|
@ -222,9 +222,9 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [100i, 200];
|
||||
/// let a = [100, 200];
|
||||
/// let mut it = a.iter().enumerate();
|
||||
/// let (x100, x200) = (100i, 200i);
|
||||
/// let (x100, x200) = (100, 200);
|
||||
/// assert_eq!(it.next().unwrap(), (0, &x100));
|
||||
/// assert_eq!(it.next().unwrap(), (1, &x200));
|
||||
/// assert!(it.next().is_none());
|
||||
|
@ -241,7 +241,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let xs = [100i, 200, 300];
|
||||
/// let xs = [100, 200, 300];
|
||||
/// let mut it = xs.iter().map(|x| *x).peekable();
|
||||
/// assert_eq!(*it.peek().unwrap(), 100);
|
||||
/// assert_eq!(it.next().unwrap(), 100);
|
||||
|
@ -265,7 +265,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 2, 1];
|
||||
/// let a = [1, 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);
|
||||
|
@ -287,7 +287,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 2, 1];
|
||||
/// let a = [1, 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);
|
||||
|
@ -307,7 +307,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().skip(3);
|
||||
/// assert_eq!(it.next().unwrap(), &4);
|
||||
/// assert_eq!(it.next().unwrap(), &5);
|
||||
|
@ -325,7 +325,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().take(3);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
|
@ -346,7 +346,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().scan(1, |fac, &x| {
|
||||
/// *fac = *fac * x;
|
||||
/// Some(*fac)
|
||||
|
@ -419,9 +419,9 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// }
|
||||
/// sum
|
||||
/// }
|
||||
/// let x = vec![1i,2,3,7,8,9];
|
||||
/// let x = vec![1,2,3,7,8,9];
|
||||
/// assert_eq!(process(x.into_iter()), 6);
|
||||
/// let x = vec![1i,2,3];
|
||||
/// let x = vec![1,2,3];
|
||||
/// assert_eq!(process(x.into_iter()), 1006);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -482,7 +482,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let b: Vec<int> = a.iter().map(|&x| x).collect();
|
||||
/// assert!(a.as_slice() == b.as_slice());
|
||||
/// ```
|
||||
|
@ -498,7 +498,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// do not.
|
||||
///
|
||||
/// ```
|
||||
/// let vec = vec![1i, 2i, 3i, 4i];
|
||||
/// let vec = vec![1, 2, 3, 4];
|
||||
/// 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]);
|
||||
|
@ -528,7 +528,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter();
|
||||
/// assert!(it.nth(2).unwrap() == &3);
|
||||
/// assert!(it.nth(2) == None);
|
||||
|
@ -549,7 +549,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().last().unwrap() == &5);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -566,7 +566,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().fold(0, |a, &b| a + b) == 15);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -586,7 +586,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter();
|
||||
/// assert!(it.count() == 5);
|
||||
/// ```
|
||||
|
@ -601,7 +601,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// 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));
|
||||
/// ```
|
||||
|
@ -618,7 +618,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter();
|
||||
/// assert!(it.any(|x| *x == 3));
|
||||
/// assert!(!it.any(|x| *x == 3));
|
||||
|
@ -668,7 +668,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// ```rust
|
||||
/// use core::num::SignedInt;
|
||||
///
|
||||
/// let xs = [-3i, 0, 1, 5, -10];
|
||||
/// let xs = [-3, 0, 1, 5, -10];
|
||||
/// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -697,7 +697,7 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
/// ```rust
|
||||
/// use core::num::SignedInt;
|
||||
///
|
||||
/// let xs = [-3i, 0, 1, 5, -10];
|
||||
/// let xs = [-3, 0, 1, 5, -10];
|
||||
/// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -950,7 +950,7 @@ pub trait AdditiveIterator<A> {
|
|||
/// ```rust
|
||||
/// use std::iter::AdditiveIterator;
|
||||
///
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a: [i32] = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().map(|&x| x);
|
||||
/// assert!(it.sum() == 15);
|
||||
/// ```
|
||||
|
@ -1033,7 +1033,7 @@ pub trait IteratorOrdExt<A> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().max().unwrap() == &5);
|
||||
/// ```
|
||||
fn max(self) -> Option<A>;
|
||||
|
@ -1043,7 +1043,7 @@ pub trait IteratorOrdExt<A> {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1i, 2, 3, 4, 5];
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().min().unwrap() == &1);
|
||||
/// ```
|
||||
fn min(self) -> Option<A>;
|
||||
|
@ -1069,16 +1069,16 @@ pub trait IteratorOrdExt<A> {
|
|||
/// let v: [int; 0] = [];
|
||||
/// assert_eq!(v.iter().min_max(), NoElements);
|
||||
///
|
||||
/// let v = [1i];
|
||||
/// let v = [1];
|
||||
/// assert!(v.iter().min_max() == OneElement(&1));
|
||||
///
|
||||
/// let v = [1i, 2, 3, 4, 5];
|
||||
/// let v = [1, 2, 3, 4, 5];
|
||||
/// assert!(v.iter().min_max() == MinMax(&1, &5));
|
||||
///
|
||||
/// let v = [1i, 2, 3, 4, 5, 6];
|
||||
/// let v = [1, 2, 3, 4, 5, 6];
|
||||
/// assert!(v.iter().min_max() == MinMax(&1, &6));
|
||||
///
|
||||
/// let v = [1i, 1, 1, 1];
|
||||
/// let v = [1, 1, 1, 1];
|
||||
/// assert!(v.iter().min_max() == MinMax(&1, &1));
|
||||
/// ```
|
||||
fn min_max(self) -> MinMaxResult<A>;
|
||||
|
@ -1179,10 +1179,10 @@ impl<T: Clone> MinMaxResult<T> {
|
|||
/// let r: MinMaxResult<int> = NoElements;
|
||||
/// assert_eq!(r.into_option(), None);
|
||||
///
|
||||
/// let r = OneElement(1i);
|
||||
/// let r = OneElement(1);
|
||||
/// assert_eq!(r.into_option(), Some((1,1)));
|
||||
///
|
||||
/// let r = MinMax(1i,2i);
|
||||
/// let r = MinMax(1, 2);
|
||||
/// assert_eq!(r.into_option(), Some((1,2)));
|
||||
/// ```
|
||||
pub fn into_option(self) -> Option<(T,T)> {
|
||||
|
@ -1261,7 +1261,7 @@ pub trait CloneIteratorExt {
|
|||
/// ```rust
|
||||
/// use std::iter::{CloneIteratorExt, count};
|
||||
///
|
||||
/// let a = count(1i,1i).take(1);
|
||||
/// let a = count(1, 1).take(1);
|
||||
/// let mut cy = a.cycle();
|
||||
/// assert_eq!(cy.next(), Some(1));
|
||||
/// assert_eq!(cy.next(), Some(1));
|
||||
|
|
|
@ -187,13 +187,13 @@ pub unsafe fn uninitialized<T>() -> 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]
|
||||
|
|
|
@ -336,7 +336,7 @@ pub trait Int
|
|||
/// ```rust
|
||||
/// use std::num::Int;
|
||||
///
|
||||
/// assert_eq!(2i.pow(4), 16);
|
||||
/// assert_eq!(2.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(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]
|
||||
#[experimental]
|
||||
|
@ -491,10 +491,10 @@ impl<T> Option<T> {
|
|||
///
|
||||
/// ```
|
||||
/// 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]
|
||||
#[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!(1909i, good_year);
|
||||
/// assert_eq!(0i, bad_year);
|
||||
/// assert_eq!(1909, good_year);
|
||||
/// assert_eq!(0, bad_year);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable]
|
||||
|
|
|
@ -125,7 +125,7 @@ macro_rules! warn {
|
|||
/// #[phase(plugin, link)] extern crate log;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let ret = 3i;
|
||||
/// let ret = 3;
|
||||
/// info!("this function is about to return: {}", ret);
|
||||
/// }
|
||||
/// ```
|
||||
|
@ -152,7 +152,7 @@ macro_rules! info {
|
|||
/// #[phase(plugin, link)] extern crate log;
|
||||
///
|
||||
/// fn main() {
|
||||
/// debug!("x = {x}, y = {y}", x=10i, y=20i);
|
||||
/// debug!("x = {x}, y = {y}", x=10, y=20);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
|
|
@ -269,7 +269,7 @@ pub trait Rng : Sized {
|
|||
/// ```
|
||||
/// use std::rand::{thread_rng, Rng};
|
||||
///
|
||||
/// let choices = [1i, 2, 4, 8, 16, 32];
|
||||
/// let choices = [1, 2, 4, 8, 16, 32];
|
||||
/// let mut rng = thread_rng();
|
||||
/// println!("{}", rng.choose(&choices));
|
||||
/// # // replace with slicing syntax when it's stable!
|
||||
|
@ -291,7 +291,7 @@ pub trait Rng : Sized {
|
|||
/// use std::rand::{thread_rng, Rng};
|
||||
///
|
||||
/// let mut rng = thread_rng();
|
||||
/// let mut y = [1i, 2, 3];
|
||||
/// let mut y = [1, 2, 3];
|
||||
/// rng.shuffle(&mut y);
|
||||
/// println!("{}", y.as_slice());
|
||||
/// rng.shuffle(&mut y);
|
||||
|
|
|
@ -164,7 +164,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(1i);
|
||||
/// set.insert(1);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable = "hasher stuff is unclear"]
|
||||
|
@ -283,8 +283,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// 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();
|
||||
/// 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();
|
||||
///
|
||||
/// // Can be seen as `a - b`.
|
||||
/// for x in a.difference(&b) {
|
||||
|
@ -292,12 +292,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, [1i].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [1].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, [4i].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [4].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn difference<'a>(&'a self, other: &'a HashSet<T, H>) -> Difference<'a, T, H> {
|
||||
|
@ -313,8 +313,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// 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();
|
||||
/// 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();
|
||||
///
|
||||
/// // Print 1, 4 in arbitrary order.
|
||||
/// for x in a.symmetric_difference(&b) {
|
||||
|
@ -325,7 +325,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, [1i, 4].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff1, [1, 4].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, H>)
|
||||
|
@ -339,8 +339,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// 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();
|
||||
/// 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();
|
||||
///
|
||||
/// // Print 2, 3 in arbitrary order.
|
||||
/// for x in a.intersection(&b) {
|
||||
|
@ -348,7 +348,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, [2i, 3].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [2, 3].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, H>) -> Intersection<'a, T, H> {
|
||||
|
@ -364,8 +364,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::HashSet;
|
||||
/// 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();
|
||||
/// 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();
|
||||
///
|
||||
/// // Print 1, 2, 3, 4 in arbitrary order.
|
||||
/// for x in a.union(&b) {
|
||||
|
@ -373,7 +373,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, [1i, 2, 3, 4].iter().map(|&x| x).collect());
|
||||
/// assert_eq!(diff, [1, 2, 3, 4].iter().map(|&x| x).collect());
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn union<'a>(&'a self, other: &'a HashSet<T, H>) -> Union<'a, T, H> {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
/// # #![allow(unreachable_code)]
|
||||
/// panic!();
|
||||
/// panic!("this is a terrible mistake!");
|
||||
/// panic!(4i); // panic with the value of 4 to be collected elsewhere
|
||||
/// panic!(4); // panic with the value of 4 to be collected elsewhere
|
||||
/// panic!("this is a {} {message}", "fancy", message = "message");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
|
@ -74,7 +74,7 @@ macro_rules! panic {
|
|||
/// // assert with a custom message
|
||||
/// # 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]
|
||||
|
@ -99,8 +99,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,7 +141,7 @@ macro_rules! assert_eq {
|
|||
/// // assert with a custom message
|
||||
/// # let x = true;
|
||||
/// debug_assert!(x, "x wasn't true!");
|
||||
/// # let a = 3i; let b = 27i;
|
||||
/// # let a = 3; let b = 27;
|
||||
/// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
|
@ -162,8 +162,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]
|
||||
|
@ -238,7 +238,7 @@ macro_rules! unimplemented {
|
|||
/// ```
|
||||
/// format!("test");
|
||||
/// format!("hello {}", "world!");
|
||||
/// format!("x = {}, y = {y}", 10i, y = 30i);
|
||||
/// format!("x = {}, y = {y}", 10, y = 30);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
#[stable]
|
||||
|
@ -338,7 +338,7 @@ macro_rules! vec {
|
|||
/// let (tx1, rx1) = channel();
|
||||
/// let (tx2, rx2) = channel();
|
||||
/// # fn long_running_task() {}
|
||||
/// # fn calculate_the_answer() -> int { 42i }
|
||||
/// # fn calculate_the_answer() -> int { 42 }
|
||||
///
|
||||
/// Thread::spawn(move|| { long_running_task(); tx1.send(()) }).detach();
|
||||
/// Thread::spawn(move|| { tx2.send(calculate_the_answer()) }).detach();
|
||||
|
@ -507,7 +507,7 @@ pub mod builtin {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// let s = concat!("test", 10i, 'b', true);
|
||||
/// let s = concat!("test", 10, '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(5i);
|
||||
/// let lock = RWLock::new(5);
|
||||
///
|
||||
/// // many reader locks can be held at once
|
||||
/// {
|
||||
|
|
Loading…
Add table
Reference in a new issue