Remove all i
suffixes
This commit is contained in:
parent
52c74e63da
commit
7f64fe4e27
@ -35,7 +35,7 @@
|
||||
//! use std::sync::Arc;
|
||||
//! use std::thread::Thread;
|
||||
//!
|
||||
//! let five = Arc::new(5i);
|
||||
//! let five = Arc::new(5);
|
||||
//!
|
||||
//! for _ in 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 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(feature = "rust1", since = "1.0.0")]
|
||||
@ -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();
|
||||
/// ```
|
||||
@ -221,7 +221,7 @@ impl<T> Clone for Arc<T> {
|
||||
/// ```
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// let five = Arc::new(5i);
|
||||
/// let five = Arc::new(5);
|
||||
///
|
||||
/// five.clone();
|
||||
/// ```
|
||||
@ -268,7 +268,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();
|
||||
/// ```
|
||||
@ -304,14 +304,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
|
||||
///
|
||||
@ -371,7 +371,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();
|
||||
///
|
||||
@ -408,7 +408,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();
|
||||
/// ```
|
||||
@ -433,7 +433,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
|
||||
@ -441,7 +441,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
|
||||
@ -475,9 +475,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) }
|
||||
|
||||
@ -490,9 +490,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) }
|
||||
}
|
||||
@ -507,9 +507,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)
|
||||
@ -524,9 +524,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) }
|
||||
|
||||
@ -539,9 +539,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) }
|
||||
|
||||
@ -554,9 +554,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) }
|
||||
|
||||
@ -569,9 +569,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) }
|
||||
}
|
||||
@ -719,14 +719,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_live() {
|
||||
let x = Arc::new(5i);
|
||||
let x = Arc::new(5);
|
||||
let y = x.downgrade();
|
||||
assert!(y.upgrade().is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dead() {
|
||||
let x = Arc::new(5i);
|
||||
let x = Arc::new(5);
|
||||
let y = x.downgrade();
|
||||
drop(x);
|
||||
assert!(y.upgrade().is_none());
|
||||
|
@ -20,7 +20,7 @@ use std::boxed::BoxAny;
|
||||
|
||||
#[test]
|
||||
fn test_owned_clone() {
|
||||
let a = Box::new(5i);
|
||||
let a = Box::new(5);
|
||||
let b: Box<int> = a.clone();
|
||||
assert!(a == b);
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ mod test {
|
||||
#[bench]
|
||||
fn alloc_owned_small(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
box 10i
|
||||
box 10
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ impl<T> Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new(value: T) -> Rc<T> {
|
||||
@ -217,7 +217,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
|
||||
///
|
||||
@ -425,7 +425,7 @@ impl<T> Clone for Rc<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// five.clone();
|
||||
/// ```
|
||||
@ -466,9 +466,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 }
|
||||
@ -482,9 +482,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 }
|
||||
@ -504,9 +504,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> {
|
||||
@ -522,9 +522,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 }
|
||||
@ -538,9 +538,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 }
|
||||
@ -554,9 +554,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 }
|
||||
@ -570,9 +570,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 }
|
||||
@ -589,9 +589,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) }
|
||||
@ -653,7 +653,7 @@ impl<T> Weak<T> {
|
||||
/// ```
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let five = Rc::new(5i);
|
||||
/// let five = Rc::new(5);
|
||||
///
|
||||
/// let weak_five = five.downgrade();
|
||||
///
|
||||
@ -682,7 +682,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
|
||||
@ -690,7 +690,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
|
||||
@ -726,7 +726,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();
|
||||
/// ```
|
||||
@ -789,7 +789,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let x = Rc::new(RefCell::new(5i));
|
||||
let x = Rc::new(RefCell::new(5));
|
||||
let y = x.clone();
|
||||
*x.borrow_mut() = 20;
|
||||
assert_eq!(*y.borrow(), 20);
|
||||
@ -797,13 +797,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_simple() {
|
||||
let x = Rc::new(5i);
|
||||
let x = Rc::new(5);
|
||||
assert_eq!(*x, 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_clone() {
|
||||
let x = Rc::new(5i);
|
||||
let x = Rc::new(5);
|
||||
let y = x.clone();
|
||||
assert_eq!(*x, 5);
|
||||
assert_eq!(*y, 5);
|
||||
@ -811,20 +811,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_destructor() {
|
||||
let x = Rc::new(box 5i);
|
||||
let x = Rc::new(box 5);
|
||||
assert_eq!(**x, 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_live() {
|
||||
let x = Rc::new(5i);
|
||||
let x = Rc::new(5);
|
||||
let y = x.downgrade();
|
||||
assert!(y.upgrade().is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dead() {
|
||||
let x = Rc::new(5i);
|
||||
let x = Rc::new(5);
|
||||
let y = x.downgrade();
|
||||
drop(x);
|
||||
assert!(y.upgrade().is_none());
|
||||
|
@ -212,7 +212,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 };
|
||||
@ -231,7 +231,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() {
|
||||
@ -251,7 +251,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() {
|
||||
@ -273,7 +273,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));
|
||||
@ -356,7 +356,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));
|
||||
@ -380,7 +380,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);
|
||||
///
|
||||
@ -402,7 +402,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);
|
||||
@ -434,7 +434,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));
|
||||
@ -457,7 +457,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
|
||||
@ -475,12 +475,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();
|
||||
@ -676,8 +676,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_iterator() {
|
||||
let data = vec!(5i, 9, 3);
|
||||
let iterout = [9i, 5, 3];
|
||||
let data = vec!(5, 9, 3);
|
||||
let iterout = [9, 5, 3];
|
||||
let heap = BinaryHeap::from_vec(data);
|
||||
let mut i = 0;
|
||||
for el in heap.iter() {
|
||||
@ -688,8 +688,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_reverse() {
|
||||
let data = vec!(5i, 9, 3);
|
||||
let iterout = vec!(3i, 5, 9);
|
||||
let data = vec!(5, 9, 3);
|
||||
let iterout = vec!(3, 5, 9);
|
||||
let pq = BinaryHeap::from_vec(data);
|
||||
|
||||
let v: Vec<int> = pq.iter().rev().map(|&x| x).collect();
|
||||
@ -698,8 +698,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_move_iter() {
|
||||
let data = vec!(5i, 9, 3);
|
||||
let iterout = vec!(9i, 5, 3);
|
||||
let data = vec!(5, 9, 3);
|
||||
let iterout = vec!(9, 5, 3);
|
||||
let pq = BinaryHeap::from_vec(data);
|
||||
|
||||
let v: Vec<int> = pq.into_iter().collect();
|
||||
@ -708,16 +708,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_move_iter_size_hint() {
|
||||
let data = vec!(5i, 9);
|
||||
let data = vec!(5, 9);
|
||||
let pq = BinaryHeap::from_vec(data);
|
||||
|
||||
let mut it = pq.into_iter();
|
||||
|
||||
assert_eq!(it.size_hint(), (2, Some(2)));
|
||||
assert_eq!(it.next(), Some(9i));
|
||||
assert_eq!(it.next(), Some(9));
|
||||
|
||||
assert_eq!(it.size_hint(), (1, Some(1)));
|
||||
assert_eq!(it.next(), Some(5i));
|
||||
assert_eq!(it.next(), Some(5));
|
||||
|
||||
assert_eq!(it.size_hint(), (0, Some(0)));
|
||||
assert_eq!(it.next(), None);
|
||||
@ -725,8 +725,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_move_iter_reverse() {
|
||||
let data = vec!(5i, 9, 3);
|
||||
let iterout = vec!(3i, 5, 9);
|
||||
let data = vec!(5, 9, 3);
|
||||
let iterout = vec!(3, 5, 9);
|
||||
let pq = BinaryHeap::from_vec(data);
|
||||
|
||||
let v: Vec<int> = pq.into_iter().rev().collect();
|
||||
@ -747,7 +747,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_push() {
|
||||
let mut heap = BinaryHeap::from_vec(vec!(2i, 4, 9));
|
||||
let mut heap = BinaryHeap::from_vec(vec!(2, 4, 9));
|
||||
assert_eq!(heap.len(), 3);
|
||||
assert!(*heap.peek().unwrap() == 9);
|
||||
heap.push(11);
|
||||
@ -769,7 +769,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_push_unique() {
|
||||
let mut heap = BinaryHeap::from_vec(vec!(box 2i, box 4, box 9));
|
||||
let mut heap = BinaryHeap::from_vec(vec!(box 2, box 4, box 9));
|
||||
assert_eq!(heap.len(), 3);
|
||||
assert!(*heap.peek().unwrap() == box 9);
|
||||
heap.push(box 11);
|
||||
@ -791,7 +791,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_push_pop() {
|
||||
let mut heap = BinaryHeap::from_vec(vec!(5i, 5, 2, 1, 3));
|
||||
let mut heap = BinaryHeap::from_vec(vec!(5, 5, 2, 1, 3));
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.push_pop(6), 6);
|
||||
assert_eq!(heap.len(), 5);
|
||||
@ -805,7 +805,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_replace() {
|
||||
let mut heap = BinaryHeap::from_vec(vec!(5i, 5, 2, 1, 3));
|
||||
let mut heap = BinaryHeap::from_vec(vec!(5, 5, 2, 1, 3));
|
||||
assert_eq!(heap.len(), 5);
|
||||
assert_eq!(heap.replace(6).unwrap(), 5);
|
||||
assert_eq!(heap.len(), 5);
|
||||
@ -830,18 +830,18 @@ mod tests {
|
||||
#[test]
|
||||
fn test_to_vec() {
|
||||
check_to_vec(vec!());
|
||||
check_to_vec(vec!(5i));
|
||||
check_to_vec(vec!(3i, 2));
|
||||
check_to_vec(vec!(2i, 3));
|
||||
check_to_vec(vec!(5i, 1, 2));
|
||||
check_to_vec(vec!(1i, 100, 2, 3));
|
||||
check_to_vec(vec!(1i, 3, 5, 7, 9, 2, 4, 6, 8, 0));
|
||||
check_to_vec(vec!(2i, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1));
|
||||
check_to_vec(vec!(9i, 11, 9, 9, 9, 9, 11, 2, 3, 4, 11, 9, 0, 0, 0, 0));
|
||||
check_to_vec(vec!(0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
check_to_vec(vec!(10i, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0));
|
||||
check_to_vec(vec!(0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 1, 2));
|
||||
check_to_vec(vec!(5i, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1));
|
||||
check_to_vec(vec!(5));
|
||||
check_to_vec(vec!(3, 2));
|
||||
check_to_vec(vec!(2, 3));
|
||||
check_to_vec(vec!(5, 1, 2));
|
||||
check_to_vec(vec!(1, 100, 2, 3));
|
||||
check_to_vec(vec!(1, 3, 5, 7, 9, 2, 4, 6, 8, 0));
|
||||
check_to_vec(vec!(2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1));
|
||||
check_to_vec(vec!(9, 11, 9, 9, 9, 9, 11, 2, 3, 4, 11, 9, 0, 0, 0, 0));
|
||||
check_to_vec(vec!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
check_to_vec(vec!(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0));
|
||||
check_to_vec(vec!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 1, 2));
|
||||
check_to_vec(vec!(5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1782,7 +1782,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_entry(){
|
||||
let xs = [(1i, 10i), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
|
||||
let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
|
||||
|
||||
let mut map: BTreeMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
|
@ -282,7 +282,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -297,7 +297,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -311,7 +311,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());
|
||||
/// ```
|
||||
@ -331,7 +331,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);
|
||||
/// ```
|
||||
@ -348,7 +348,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);
|
||||
@ -369,7 +369,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);
|
||||
@ -411,7 +411,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);
|
||||
@ -438,8 +438,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -461,7 +461,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);
|
||||
/// ```
|
||||
@ -731,7 +731,7 @@ mod test {
|
||||
fn test_clone_eq() {
|
||||
let mut m = BTreeSet::new();
|
||||
|
||||
m.insert(1i);
|
||||
m.insert(1);
|
||||
m.insert(2);
|
||||
|
||||
assert!(m.clone() == m);
|
||||
@ -742,11 +742,11 @@ mod test {
|
||||
let mut x = BTreeSet::new();
|
||||
let mut y = BTreeSet::new();
|
||||
|
||||
x.insert(1i);
|
||||
x.insert(1);
|
||||
x.insert(2);
|
||||
x.insert(3);
|
||||
|
||||
y.insert(3i);
|
||||
y.insert(3);
|
||||
y.insert(2);
|
||||
y.insert(1);
|
||||
|
||||
@ -874,7 +874,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_from_iter() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
let set: BTreeSet<int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
|
@ -235,9 +235,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(&mut b);
|
||||
@ -529,7 +529,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());
|
||||
/// ```
|
||||
@ -548,7 +548,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));
|
||||
/// ```
|
||||
@ -766,7 +766,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]
|
||||
@ -964,7 +964,7 @@ mod tests {
|
||||
assert_eq!(m.pop_front(), Some(box 1));
|
||||
|
||||
let mut n = DList::new();
|
||||
n.push_front(2i);
|
||||
n.push_front(2);
|
||||
n.push_front(3);
|
||||
{
|
||||
assert_eq!(n.front().unwrap(), &3);
|
||||
@ -984,7 +984,7 @@ mod tests {
|
||||
|
||||
#[cfg(test)]
|
||||
fn generate_test() -> DList<int> {
|
||||
list_from(&[0i,1,2,3,4,5,6])
|
||||
list_from(&[0,1,2,3,4,5,6])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -1007,7 +1007,7 @@ mod tests {
|
||||
{
|
||||
let mut m = DList::new();
|
||||
let mut n = DList::new();
|
||||
n.push_back(2i);
|
||||
n.push_back(2);
|
||||
m.append(&mut n);
|
||||
check_links(&m);
|
||||
assert_eq!(m.len(), 1);
|
||||
@ -1019,7 +1019,7 @@ mod tests {
|
||||
{
|
||||
let mut m = DList::new();
|
||||
let mut n = DList::new();
|
||||
m.push_back(2i);
|
||||
m.push_back(2);
|
||||
m.append(&mut n);
|
||||
check_links(&m);
|
||||
assert_eq!(m.len(), 1);
|
||||
@ -1028,8 +1028,8 @@ mod tests {
|
||||
}
|
||||
|
||||
// Non-empty to non-empty
|
||||
let v = vec![1i,2,3,4,5];
|
||||
let u = vec![9i,8,1,2,3,4,5];
|
||||
let v = vec![1,2,3,4,5];
|
||||
let u = vec![9,8,1,2,3,4,5];
|
||||
let mut m = list_from(v.as_slice());
|
||||
let mut n = list_from(u.as_slice());
|
||||
m.append(&mut n);
|
||||
@ -1054,7 +1054,7 @@ mod tests {
|
||||
// singleton
|
||||
{
|
||||
let mut m = DList::new();
|
||||
m.push_back(1i);
|
||||
m.push_back(1);
|
||||
|
||||
let p = m.split_off(0);
|
||||
assert_eq!(m.len(), 0);
|
||||
@ -1065,29 +1065,29 @@ mod tests {
|
||||
|
||||
// not singleton, forwards
|
||||
{
|
||||
let u = vec![1i,2,3,4,5];
|
||||
let u = vec![1,2,3,4,5];
|
||||
let mut m = list_from(u.as_slice());
|
||||
let mut n = m.split_off(2);
|
||||
assert_eq!(m.len(), 2);
|
||||
assert_eq!(n.len(), 3);
|
||||
for elt in 1i..3 {
|
||||
for elt in 1..3 {
|
||||
assert_eq!(m.pop_front(), Some(elt));
|
||||
}
|
||||
for elt in 3i..6 {
|
||||
for elt in 3..6 {
|
||||
assert_eq!(n.pop_front(), Some(elt));
|
||||
}
|
||||
}
|
||||
// not singleton, backwards
|
||||
{
|
||||
let u = vec![1i,2,3,4,5];
|
||||
let u = vec![1,2,3,4,5];
|
||||
let mut m = list_from(u.as_slice());
|
||||
let mut n = m.split_off(4);
|
||||
assert_eq!(m.len(), 4);
|
||||
assert_eq!(n.len(), 1);
|
||||
for elt in 1i..5 {
|
||||
for elt in 1..5 {
|
||||
assert_eq!(m.pop_front(), Some(elt));
|
||||
}
|
||||
for elt in 5i..6 {
|
||||
for elt in 5..6 {
|
||||
assert_eq!(n.pop_front(), Some(elt));
|
||||
}
|
||||
}
|
||||
@ -1102,7 +1102,7 @@ mod tests {
|
||||
}
|
||||
let mut n = DList::new();
|
||||
assert_eq!(n.iter().next(), None);
|
||||
n.push_front(4i);
|
||||
n.push_front(4);
|
||||
let mut it = n.iter();
|
||||
assert_eq!(it.size_hint(), (1, Some(1)));
|
||||
assert_eq!(it.next().unwrap(), &4);
|
||||
@ -1113,7 +1113,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_iterator_clone() {
|
||||
let mut n = DList::new();
|
||||
n.push_back(2i);
|
||||
n.push_back(2);
|
||||
n.push_back(3);
|
||||
n.push_back(4);
|
||||
let mut it = n.iter();
|
||||
@ -1128,7 +1128,7 @@ mod tests {
|
||||
fn test_iterator_double_end() {
|
||||
let mut n = DList::new();
|
||||
assert_eq!(n.iter().next(), None);
|
||||
n.push_front(4i);
|
||||
n.push_front(4);
|
||||
n.push_front(5);
|
||||
n.push_front(6);
|
||||
let mut it = n.iter();
|
||||
@ -1150,7 +1150,7 @@ mod tests {
|
||||
}
|
||||
let mut n = DList::new();
|
||||
assert_eq!(n.iter().rev().next(), None);
|
||||
n.push_front(4i);
|
||||
n.push_front(4);
|
||||
let mut it = n.iter().rev();
|
||||
assert_eq!(it.size_hint(), (1, Some(1)));
|
||||
assert_eq!(it.next().unwrap(), &4);
|
||||
@ -1169,7 +1169,7 @@ mod tests {
|
||||
assert_eq!(len, 0);
|
||||
let mut n = DList::new();
|
||||
assert!(n.iter_mut().next().is_none());
|
||||
n.push_front(4i);
|
||||
n.push_front(4);
|
||||
n.push_back(5);
|
||||
let mut it = n.iter_mut();
|
||||
assert_eq!(it.size_hint(), (2, Some(2)));
|
||||
@ -1183,7 +1183,7 @@ mod tests {
|
||||
fn test_iterator_mut_double_end() {
|
||||
let mut n = DList::new();
|
||||
assert!(n.iter_mut().next_back().is_none());
|
||||
n.push_front(4i);
|
||||
n.push_front(4);
|
||||
n.push_front(5);
|
||||
n.push_front(6);
|
||||
let mut it = n.iter_mut();
|
||||
@ -1199,7 +1199,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_insert_prev() {
|
||||
let mut m = list_from(&[0i,2,4,6,8]);
|
||||
let mut m = list_from(&[0,2,4,6,8]);
|
||||
let len = m.len();
|
||||
{
|
||||
let mut it = m.iter_mut();
|
||||
@ -1232,7 +1232,7 @@ mod tests {
|
||||
}
|
||||
let mut n = DList::new();
|
||||
assert!(n.iter_mut().rev().next().is_none());
|
||||
n.push_front(4i);
|
||||
n.push_front(4);
|
||||
let mut it = n.iter_mut().rev();
|
||||
assert!(it.next().is_some());
|
||||
assert!(it.next().is_none());
|
||||
@ -1240,7 +1240,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_send() {
|
||||
let n = list_from(&[1i,2,3]);
|
||||
let n = list_from(&[1,2,3]);
|
||||
Thread::scoped(move || {
|
||||
check_links(&n);
|
||||
let a: &[_] = &[&1,&2,&3];
|
||||
@ -1258,8 +1258,8 @@ mod tests {
|
||||
m.push_back(1);
|
||||
assert!(n == m);
|
||||
|
||||
let n = list_from(&[2i,3,4]);
|
||||
let m = list_from(&[1i,2,3]);
|
||||
let n = list_from(&[2,3,4]);
|
||||
let m = list_from(&[1,2,3]);
|
||||
assert!(n != m);
|
||||
}
|
||||
|
||||
@ -1270,11 +1270,11 @@ mod tests {
|
||||
|
||||
assert!(hash::hash::<_, SipHasher>(&x) == hash::hash::<_, SipHasher>(&y));
|
||||
|
||||
x.push_back(1i);
|
||||
x.push_back(1);
|
||||
x.push_back(2);
|
||||
x.push_back(3);
|
||||
|
||||
y.push_front(3i);
|
||||
y.push_front(3);
|
||||
y.push_front(2);
|
||||
y.push_front(1);
|
||||
|
||||
@ -1284,7 +1284,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_ord() {
|
||||
let n: DList<int> = list_from(&[]);
|
||||
let m = list_from(&[1i,2,3]);
|
||||
let m = list_from(&[1,2,3]);
|
||||
assert!(n < m);
|
||||
assert!(m > n);
|
||||
assert!(n <= n);
|
||||
@ -1334,7 +1334,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let list: DList<int> = (0i..10).collect();
|
||||
let list: DList<i32> = (0..10).collect();
|
||||
assert_eq!(format!("{:?}", list), "DList [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
|
||||
|
||||
let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
|
||||
@ -1384,7 +1384,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_collect_into(b: &mut test::Bencher) {
|
||||
let v = &[0i; 64];
|
||||
let v = &[0; 64];
|
||||
b.iter(|| {
|
||||
let _: DList<int> = v.iter().map(|x| *x).collect();
|
||||
})
|
||||
@ -1426,7 +1426,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_iter(b: &mut test::Bencher) {
|
||||
let v = &[0i; 128];
|
||||
let v = &[0; 128];
|
||||
let m: DList<int> = v.iter().map(|&x|x).collect();
|
||||
b.iter(|| {
|
||||
assert!(m.iter().count() == 128);
|
||||
@ -1434,7 +1434,7 @@ mod tests {
|
||||
}
|
||||
#[bench]
|
||||
fn bench_iter_mut(b: &mut test::Bencher) {
|
||||
let v = &[0i; 128];
|
||||
let v = &[0; 128];
|
||||
let mut m: DList<int> = v.iter().map(|&x|x).collect();
|
||||
b.iter(|| {
|
||||
assert!(m.iter_mut().count() == 128);
|
||||
@ -1442,7 +1442,7 @@ mod tests {
|
||||
}
|
||||
#[bench]
|
||||
fn bench_iter_rev(b: &mut test::Bencher) {
|
||||
let v = &[0i; 128];
|
||||
let v = &[0; 128];
|
||||
let m: DList<int> = v.iter().map(|&x|x).collect();
|
||||
b.iter(|| {
|
||||
assert!(m.iter().rev().count() == 128);
|
||||
@ -1450,7 +1450,7 @@ mod tests {
|
||||
}
|
||||
#[bench]
|
||||
fn bench_iter_mut_rev(b: &mut test::Bencher) {
|
||||
let v = &[0i; 128];
|
||||
let v = &[0; 128];
|
||||
let mut m: DList<int> = v.iter().map(|&x|x).collect();
|
||||
b.iter(|| {
|
||||
assert!(m.iter_mut().rev().count() == 128);
|
||||
|
@ -186,7 +186,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);
|
||||
@ -209,7 +209,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) {
|
||||
@ -243,7 +243,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);
|
||||
@ -269,7 +269,7 @@ impl<T> RingBuf<T> {
|
||||
/// ```
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let buf: RingBuf<int> = RingBuf::with_capacity(10);
|
||||
/// let buf: RingBuf<i32> = RingBuf::with_capacity(10);
|
||||
/// assert!(buf.capacity() >= 10);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -292,7 +292,7 @@ impl<T> RingBuf<T> {
|
||||
/// ```
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf: RingBuf<int> = vec![1].into_iter().collect();
|
||||
/// let mut buf: RingBuf<i32> = vec![1].into_iter().collect();
|
||||
/// buf.reserve_exact(10);
|
||||
/// assert!(buf.capacity() >= 11);
|
||||
/// ```
|
||||
@ -313,7 +313,7 @@ impl<T> RingBuf<T> {
|
||||
/// ```
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf: RingBuf<int> = vec![1].into_iter().collect();
|
||||
/// let mut buf: RingBuf<i32> = vec![1].into_iter().collect();
|
||||
/// buf.reserve(10);
|
||||
/// assert!(buf.capacity() >= 11);
|
||||
/// ```
|
||||
@ -473,8 +473,8 @@ impl<T> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(10i);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(15);
|
||||
/// buf.truncate(1);
|
||||
/// assert_eq!(buf.len(), 1);
|
||||
@ -496,11 +496,11 @@ 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];
|
||||
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b);
|
||||
/// assert_eq!(buf.iter().collect::<Vec<&i32>>().as_slice(), b);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn iter(&self) -> Iter<T> {
|
||||
@ -519,14 +519,14 @@ 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() {
|
||||
/// *num = *num - 2;
|
||||
/// }
|
||||
/// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
|
||||
/// assert_eq!(&buf.iter_mut().collect::<Vec<&mut int>>()[], b);
|
||||
/// assert_eq!(&buf.iter_mut().collect::<Vec<&mut i32>>()[], b);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
|
||||
@ -600,7 +600,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -615,7 +615,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -630,7 +630,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());
|
||||
/// ```
|
||||
@ -651,7 +651,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());
|
||||
/// ```
|
||||
@ -672,9 +672,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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn front(&self) -> Option<&T> {
|
||||
@ -692,13 +692,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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn front_mut(&mut self) -> Option<&mut T> {
|
||||
@ -716,9 +716,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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn back(&self) -> Option<&T> {
|
||||
@ -736,13 +736,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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn back_mut(&mut self) -> Option<&mut T> {
|
||||
@ -759,11 +759,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -785,9 +785,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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn push_front(&mut self, t: T) {
|
||||
@ -809,7 +809,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());
|
||||
/// ```
|
||||
@ -835,7 +835,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));
|
||||
/// ```
|
||||
@ -869,7 +869,7 @@ impl<T> RingBuf<T> {
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// assert_eq!(buf.swap_back_remove(0), None);
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(99);
|
||||
/// buf.push_back(15);
|
||||
/// buf.push_back(20);
|
||||
@ -902,11 +902,11 @@ impl<T> RingBuf<T> {
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// assert_eq!(buf.swap_front_remove(0), None);
|
||||
/// buf.push_back(15i);
|
||||
/// buf.push_back(15);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(99);
|
||||
/// buf.push_back(20i);
|
||||
/// buf.push_back(20);
|
||||
/// assert_eq!(buf.swap_front_remove(3), Some(99));
|
||||
/// ```
|
||||
#[unstable(feature = "collections",
|
||||
@ -934,7 +934,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));
|
||||
@ -1136,9 +1136,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));
|
||||
@ -1301,8 +1301,8 @@ impl<T: Clone> RingBuf<T> {
|
||||
/// use std::collections::RingBuf;
|
||||
///
|
||||
/// let mut buf = RingBuf::new();
|
||||
/// buf.push_back(5i);
|
||||
/// buf.push_back(10i);
|
||||
/// buf.push_back(5);
|
||||
/// buf.push_back(10);
|
||||
/// buf.push_back(15);
|
||||
/// buf.resize(2, 0);
|
||||
/// buf.resize(6, 20);
|
||||
@ -1650,8 +1650,8 @@ mod tests {
|
||||
fn test_simple() {
|
||||
let mut d = RingBuf::new();
|
||||
assert_eq!(d.len(), 0u);
|
||||
d.push_front(17i);
|
||||
d.push_front(42i);
|
||||
d.push_front(17);
|
||||
d.push_front(42);
|
||||
d.push_back(137);
|
||||
assert_eq!(d.len(), 3u);
|
||||
d.push_back(137);
|
||||
@ -1769,7 +1769,7 @@ mod tests {
|
||||
fn bench_push_back_100(b: &mut test::Bencher) {
|
||||
let mut deq = RingBuf::with_capacity(101);
|
||||
b.iter(|| {
|
||||
for i in 0i..100 {
|
||||
for i in 0..100 {
|
||||
deq.push_back(i);
|
||||
}
|
||||
deq.head = 0;
|
||||
@ -1781,7 +1781,7 @@ mod tests {
|
||||
fn bench_push_front_100(b: &mut test::Bencher) {
|
||||
let mut deq = RingBuf::with_capacity(101);
|
||||
b.iter(|| {
|
||||
for i in 0i..100 {
|
||||
for i in 0..100 {
|
||||
deq.push_front(i);
|
||||
}
|
||||
deq.head = 0;
|
||||
@ -1791,7 +1791,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_pop_back_100(b: &mut test::Bencher) {
|
||||
let mut deq: RingBuf<int> = RingBuf::with_capacity(101);
|
||||
let mut deq: RingBuf<i32> = RingBuf::with_capacity(101);
|
||||
|
||||
b.iter(|| {
|
||||
deq.head = 100;
|
||||
@ -1804,7 +1804,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_pop_front_100(b: &mut test::Bencher) {
|
||||
let mut deq: RingBuf<int> = RingBuf::with_capacity(101);
|
||||
let mut deq: RingBuf<i32> = RingBuf::with_capacity(101);
|
||||
|
||||
b.iter(|| {
|
||||
deq.head = 100;
|
||||
@ -1819,7 +1819,7 @@ mod tests {
|
||||
fn bench_grow_1025(b: &mut test::Bencher) {
|
||||
b.iter(|| {
|
||||
let mut deq = RingBuf::new();
|
||||
for i in 0i..1025 {
|
||||
for i in 0..1025 {
|
||||
deq.push_front(i);
|
||||
}
|
||||
test::black_box(deq);
|
||||
@ -1828,7 +1828,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_iter_1000(b: &mut test::Bencher) {
|
||||
let ring: RingBuf<int> = (0i..1000).collect();
|
||||
let ring: RingBuf<i32> = (0..1000).collect();
|
||||
|
||||
b.iter(|| {
|
||||
let mut sum = 0;
|
||||
@ -1841,7 +1841,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_mut_iter_1000(b: &mut test::Bencher) {
|
||||
let mut ring: RingBuf<int> = (0i..1000).collect();
|
||||
let mut ring: RingBuf<i32> = (0..1000).collect();
|
||||
|
||||
b.iter(|| {
|
||||
let mut sum = 0;
|
||||
@ -1854,28 +1854,28 @@ mod tests {
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
enum Taggy {
|
||||
One(int),
|
||||
Two(int, int),
|
||||
Three(int, int, int),
|
||||
One(i32),
|
||||
Two(i32, i32),
|
||||
Three(i32, i32, i32),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
enum Taggypar<T> {
|
||||
Onepar(int),
|
||||
Twopar(int, int),
|
||||
Threepar(int, int, int),
|
||||
Onepar(i32),
|
||||
Twopar(i32, i32),
|
||||
Threepar(i32, i32, i32),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
struct RecCy {
|
||||
x: int,
|
||||
y: int,
|
||||
x: i32,
|
||||
y: i32,
|
||||
t: Taggy
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_param_int() {
|
||||
test_parameterized::<int>(5, 72, 64, 175);
|
||||
test_parameterized::<i32>(5, 72, 64, 175);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1885,10 +1885,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_param_taggypar() {
|
||||
test_parameterized::<Taggypar<int>>(Onepar::<int>(1),
|
||||
Twopar::<int>(1, 2),
|
||||
Threepar::<int>(1, 2, 3),
|
||||
Twopar::<int>(17, 42));
|
||||
test_parameterized::<Taggypar<i32>>(Onepar::<i32>(1),
|
||||
Twopar::<i32>(1, 2),
|
||||
Threepar::<i32>(1, 2, 3),
|
||||
Twopar::<i32>(17, 42));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1903,17 +1903,17 @@ mod tests {
|
||||
#[test]
|
||||
fn test_with_capacity() {
|
||||
let mut d = RingBuf::with_capacity(0);
|
||||
d.push_back(1i);
|
||||
d.push_back(1);
|
||||
assert_eq!(d.len(), 1);
|
||||
let mut d = RingBuf::with_capacity(50);
|
||||
d.push_back(1i);
|
||||
d.push_back(1);
|
||||
assert_eq!(d.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_capacity_non_power_two() {
|
||||
let mut d3 = RingBuf::with_capacity(3);
|
||||
d3.push_back(1i);
|
||||
d3.push_back(1);
|
||||
|
||||
// X = None, | = lo
|
||||
// [|1, X, X]
|
||||
@ -1977,10 +1977,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_swap() {
|
||||
let mut d: RingBuf<int> = (0i..5).collect();
|
||||
let mut d: RingBuf<i32> = (0..5).collect();
|
||||
d.pop_front();
|
||||
d.swap(0, 3);
|
||||
assert_eq!(d.iter().map(|&x|x).collect::<Vec<int>>(), vec!(4, 2, 3, 1));
|
||||
assert_eq!(d.iter().map(|&x|x).collect::<Vec<i32>>(), vec!(4, 2, 3, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1989,20 +1989,20 @@ mod tests {
|
||||
assert_eq!(d.iter().next(), None);
|
||||
assert_eq!(d.iter().size_hint(), (0, Some(0)));
|
||||
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
{
|
||||
let b: &[_] = &[&0,&1,&2,&3,&4];
|
||||
assert_eq!(d.iter().collect::<Vec<&int>>(), b);
|
||||
assert_eq!(d.iter().collect::<Vec<&i32>>(), b);
|
||||
}
|
||||
|
||||
for i in 6i..9 {
|
||||
for i in 6..9 {
|
||||
d.push_front(i);
|
||||
}
|
||||
{
|
||||
let b: &[_] = &[&8,&7,&6,&0,&1,&2,&3,&4];
|
||||
assert_eq!(d.iter().collect::<Vec<&int>>(), b);
|
||||
assert_eq!(d.iter().collect::<Vec<&i32>>(), b);
|
||||
}
|
||||
|
||||
let mut it = d.iter();
|
||||
@ -2020,19 +2020,19 @@ mod tests {
|
||||
let mut d = RingBuf::new();
|
||||
assert_eq!(d.iter().rev().next(), None);
|
||||
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
{
|
||||
let b: &[_] = &[&4,&3,&2,&1,&0];
|
||||
assert_eq!(d.iter().rev().collect::<Vec<&int>>(), b);
|
||||
assert_eq!(d.iter().rev().collect::<Vec<&i32>>(), b);
|
||||
}
|
||||
|
||||
for i in 6i..9 {
|
||||
for i in 6..9 {
|
||||
d.push_front(i);
|
||||
}
|
||||
let b: &[_] = &[&4,&3,&2,&1,&0,&6,&7,&8];
|
||||
assert_eq!(d.iter().rev().collect::<Vec<&int>>(), b);
|
||||
assert_eq!(d.iter().rev().collect::<Vec<&i32>>(), b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -2040,13 +2040,13 @@ mod tests {
|
||||
let mut d = RingBuf::with_capacity(3);
|
||||
assert!(d.iter_mut().rev().next().is_none());
|
||||
|
||||
d.push_back(1i);
|
||||
d.push_back(1);
|
||||
d.push_back(2);
|
||||
d.push_back(3);
|
||||
assert_eq!(d.pop_front(), Some(1));
|
||||
d.push_back(4);
|
||||
|
||||
assert_eq!(d.iter_mut().rev().map(|x| *x).collect::<Vec<int>>(),
|
||||
assert_eq!(d.iter_mut().rev().map(|x| *x).collect::<Vec<i32>>(),
|
||||
vec!(4, 3, 2));
|
||||
}
|
||||
|
||||
@ -2101,7 +2101,7 @@ mod tests {
|
||||
|
||||
// Empty iter
|
||||
{
|
||||
let d: RingBuf<int> = RingBuf::new();
|
||||
let d: RingBuf<i32> = RingBuf::new();
|
||||
let mut iter = d.into_iter();
|
||||
|
||||
assert_eq!(iter.size_hint(), (0, Some(0)));
|
||||
@ -2112,35 +2112,35 @@ mod tests {
|
||||
// simple iter
|
||||
{
|
||||
let mut d = RingBuf::new();
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
|
||||
let b = vec![0,1,2,3,4];
|
||||
assert_eq!(d.into_iter().collect::<Vec<int>>(), b);
|
||||
assert_eq!(d.into_iter().collect::<Vec<i32>>(), b);
|
||||
}
|
||||
|
||||
// wrapped iter
|
||||
{
|
||||
let mut d = RingBuf::new();
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
for i in 6i..9 {
|
||||
for i in 6..9 {
|
||||
d.push_front(i);
|
||||
}
|
||||
|
||||
let b = vec![8,7,6,0,1,2,3,4];
|
||||
assert_eq!(d.into_iter().collect::<Vec<int>>(), b);
|
||||
assert_eq!(d.into_iter().collect::<Vec<i32>>(), b);
|
||||
}
|
||||
|
||||
// partially used
|
||||
{
|
||||
let mut d = RingBuf::new();
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
for i in 6i..9 {
|
||||
for i in 6..9 {
|
||||
d.push_front(i);
|
||||
}
|
||||
|
||||
@ -2160,7 +2160,7 @@ mod tests {
|
||||
|
||||
// Empty iter
|
||||
{
|
||||
let mut d: RingBuf<int> = RingBuf::new();
|
||||
let mut d: RingBuf<i32> = RingBuf::new();
|
||||
|
||||
{
|
||||
let mut iter = d.drain();
|
||||
@ -2176,32 +2176,32 @@ mod tests {
|
||||
// simple iter
|
||||
{
|
||||
let mut d = RingBuf::new();
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
|
||||
assert_eq!(d.drain().collect::<Vec<int>>(), [0, 1, 2, 3, 4]);
|
||||
assert_eq!(d.drain().collect::<Vec<i32>>(), [0, 1, 2, 3, 4]);
|
||||
assert!(d.is_empty());
|
||||
}
|
||||
|
||||
// wrapped iter
|
||||
{
|
||||
let mut d = RingBuf::new();
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
for i in 6i..9 {
|
||||
d.push_front(i);
|
||||
}
|
||||
|
||||
assert_eq!(d.drain().collect::<Vec<int>>(), [8,7,6,0,1,2,3,4]);
|
||||
assert_eq!(d.drain().collect::<Vec<i32>>(), [8,7,6,0,1,2,3,4]);
|
||||
assert!(d.is_empty());
|
||||
}
|
||||
|
||||
// partially used
|
||||
{
|
||||
let mut d = RingBuf::new();
|
||||
for i in 0i..5 {
|
||||
for i in 0..5 {
|
||||
d.push_back(i);
|
||||
}
|
||||
for i in 6i..9 {
|
||||
@ -2225,9 +2225,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_from_iter() {
|
||||
use core::iter;
|
||||
let v = vec!(1i,2,3,4,5,6,7);
|
||||
let deq: RingBuf<int> = v.iter().map(|&x| x).collect();
|
||||
let u: Vec<int> = deq.iter().map(|&x| x).collect();
|
||||
let v = vec!(1,2,3,4,5,6,7);
|
||||
let deq: RingBuf<i32> = v.iter().map(|&x| x).collect();
|
||||
let u: Vec<i32> = deq.iter().map(|&x| x).collect();
|
||||
assert_eq!(u, v);
|
||||
|
||||
let seq = iter::count(0u, 2).take(256);
|
||||
@ -2241,7 +2241,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let mut d = RingBuf::new();
|
||||
d.push_front(17i);
|
||||
d.push_front(17);
|
||||
d.push_front(42);
|
||||
d.push_back(137);
|
||||
d.push_back(137);
|
||||
@ -2259,7 +2259,7 @@ mod tests {
|
||||
fn test_eq() {
|
||||
let mut d = RingBuf::new();
|
||||
assert!(d == RingBuf::with_capacity(0));
|
||||
d.push_front(137i);
|
||||
d.push_front(137);
|
||||
d.push_front(17);
|
||||
d.push_front(42);
|
||||
d.push_back(137);
|
||||
@ -2281,12 +2281,12 @@ mod tests {
|
||||
let mut x = RingBuf::new();
|
||||
let mut y = RingBuf::new();
|
||||
|
||||
x.push_back(1i);
|
||||
x.push_back(1);
|
||||
x.push_back(2);
|
||||
x.push_back(3);
|
||||
|
||||
y.push_back(0i);
|
||||
y.push_back(1i);
|
||||
y.push_back(0);
|
||||
y.push_back(1);
|
||||
y.pop_front();
|
||||
y.push_back(2);
|
||||
y.push_back(3);
|
||||
@ -2298,7 +2298,7 @@ mod tests {
|
||||
fn test_ord() {
|
||||
let x = RingBuf::new();
|
||||
let mut y = RingBuf::new();
|
||||
y.push_back(1i);
|
||||
y.push_back(1);
|
||||
y.push_back(2);
|
||||
y.push_back(3);
|
||||
assert!(x < y);
|
||||
@ -2309,7 +2309,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let ringbuf: RingBuf<int> = (0i..10).collect();
|
||||
let ringbuf: RingBuf<i32> = (0..10).collect();
|
||||
assert_eq!(format!("{:?}", ringbuf), "RingBuf [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
|
||||
|
||||
let ringbuf: RingBuf<&str> = vec!["just", "one", "test", "more"].iter()
|
||||
@ -2389,41 +2389,41 @@ mod tests {
|
||||
// test growth path A
|
||||
// [T o o H] -> [T o o H . . . . ]
|
||||
let mut ring = RingBuf::with_capacity(4);
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
ring.push_back(i);
|
||||
}
|
||||
ring.reserve(7);
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
assert_eq!(ring.pop_front(), Some(i));
|
||||
}
|
||||
|
||||
// test growth path B
|
||||
// [H T o o] -> [. T o o H . . . ]
|
||||
let mut ring = RingBuf::with_capacity(4);
|
||||
for i in 0i..1 {
|
||||
for i in 0..1 {
|
||||
ring.push_back(i);
|
||||
assert_eq!(ring.pop_front(), Some(i));
|
||||
}
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
ring.push_back(i);
|
||||
}
|
||||
ring.reserve(7);
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
assert_eq!(ring.pop_front(), Some(i));
|
||||
}
|
||||
|
||||
// test growth path C
|
||||
// [o o H T] -> [o o H . . . . T ]
|
||||
let mut ring = RingBuf::with_capacity(4);
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
ring.push_back(i);
|
||||
assert_eq!(ring.pop_front(), Some(i));
|
||||
}
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
ring.push_back(i);
|
||||
}
|
||||
ring.reserve(7);
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
assert_eq!(ring.pop_front(), Some(i));
|
||||
}
|
||||
}
|
||||
@ -2431,7 +2431,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_get() {
|
||||
let mut ring = RingBuf::new();
|
||||
ring.push_back(0i);
|
||||
ring.push_back(0);
|
||||
assert_eq!(ring.get(0), Some(&0));
|
||||
assert_eq!(ring.get(1), None);
|
||||
|
||||
@ -2463,7 +2463,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_get_mut() {
|
||||
let mut ring = RingBuf::new();
|
||||
for i in 0i..3 {
|
||||
for i in 0..3 {
|
||||
ring.push_back(i);
|
||||
}
|
||||
|
||||
@ -2633,8 +2633,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_front() {
|
||||
let mut ring = RingBuf::new();
|
||||
ring.push_back(10i);
|
||||
ring.push_back(20i);
|
||||
ring.push_back(10);
|
||||
ring.push_back(20);
|
||||
assert_eq!(ring.front(), Some(&10));
|
||||
ring.pop_front();
|
||||
assert_eq!(ring.front(), Some(&20));
|
||||
@ -2644,7 +2644,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_as_slices() {
|
||||
let mut ring: RingBuf<int> = RingBuf::with_capacity(127);
|
||||
let mut ring: RingBuf<i32> = RingBuf::with_capacity(127);
|
||||
let cap = ring.capacity() as int;
|
||||
let first = cap/2;
|
||||
let last = cap - first;
|
||||
@ -2672,7 +2672,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_as_mut_slices() {
|
||||
let mut ring: RingBuf<int> = RingBuf::with_capacity(127);
|
||||
let mut ring: RingBuf<i32> = RingBuf::with_capacity(127);
|
||||
let cap = ring.capacity() as int;
|
||||
let first = cap/2;
|
||||
let last = cap - first;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1291,8 +1291,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_simple_types() {
|
||||
assert_eq!(1i.to_string(), "1");
|
||||
assert_eq!((-1i).to_string(), "-1");
|
||||
assert_eq!(1.to_string(), "1");
|
||||
assert_eq!((-1).to_string(), "-1");
|
||||
assert_eq!(200u.to_string(), "200");
|
||||
assert_eq!(2u8.to_string(), "2");
|
||||
assert_eq!(true.to_string(), "true");
|
||||
@ -1304,9 +1304,9 @@ mod tests {
|
||||
fn test_vectors() {
|
||||
let x: Vec<int> = vec![];
|
||||
assert_eq!(format!("{:?}", x), "[]");
|
||||
assert_eq!(format!("{:?}", vec![1i]), "[1]");
|
||||
assert_eq!(format!("{:?}", vec![1i, 2, 3]), "[1, 2, 3]");
|
||||
assert!(format!("{:?}", vec![vec![], vec![1i], vec![1i, 1]]) ==
|
||||
assert_eq!(format!("{:?}", vec![1]), "[1]");
|
||||
assert_eq!(format!("{:?}", vec![1, 2, 3]), "[1, 2, 3]");
|
||||
assert!(format!("{:?}", vec![vec![], vec![1], vec![1, 1]]) ==
|
||||
"[[], [1], [1, 1]]");
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,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);
|
||||
@ -82,7 +82,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]);
|
||||
@ -90,13 +90,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]);
|
||||
/// ```
|
||||
@ -106,9 +106,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() {
|
||||
@ -186,7 +186,7 @@ impl<T> Vec<T> {
|
||||
/// assert_eq!(vec.len(), 0);
|
||||
///
|
||||
/// // These are all done without reallocating...
|
||||
/// for i in 0i..10 {
|
||||
/// for i in 0..10 {
|
||||
/// vec.push(i);
|
||||
/// }
|
||||
///
|
||||
@ -220,7 +220,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();
|
||||
@ -239,7 +239,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]);
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
@ -395,7 +395,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]);
|
||||
/// ```
|
||||
@ -419,7 +419,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]
|
||||
@ -522,7 +522,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);
|
||||
@ -560,7 +560,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]);
|
||||
/// ```
|
||||
@ -594,7 +594,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]);
|
||||
/// ```
|
||||
@ -627,7 +627,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));
|
||||
/// ```
|
||||
@ -665,7 +665,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]);
|
||||
/// ```
|
||||
@ -758,7 +758,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut v = vec![1i, 2, 3];
|
||||
/// let mut v = vec![1, 2, 3];
|
||||
///
|
||||
/// v.clear();
|
||||
///
|
||||
@ -775,7 +775,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let a = vec![1i, 2, 3];
|
||||
/// let a = vec![1, 2, 3];
|
||||
/// assert_eq!(a.len(), 3);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -790,7 +790,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(feature = "rust1", since = "1.0.0")]
|
||||
@ -1045,7 +1045,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]);
|
||||
/// ```
|
||||
@ -1069,8 +1069,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]
|
||||
@ -1103,11 +1103,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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn dedup(&mut self) {
|
||||
@ -1487,7 +1487,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]
|
||||
@ -1969,7 +1969,7 @@ mod tests {
|
||||
v.reserve(2);
|
||||
assert!(v.capacity() >= 2);
|
||||
|
||||
for i in 0i..16 {
|
||||
for i in 0..16 {
|
||||
v.push(i);
|
||||
}
|
||||
|
||||
@ -1988,13 +1988,13 @@ mod tests {
|
||||
let mut v = Vec::new();
|
||||
let mut w = Vec::new();
|
||||
|
||||
v.extend(0i..3);
|
||||
for i in 0i..3 { w.push(i) }
|
||||
v.extend(0..3);
|
||||
for i in 0..3 { w.push(i) }
|
||||
|
||||
assert_eq!(v, w);
|
||||
|
||||
v.extend(3i..10);
|
||||
for i in 3i..10 { w.push(i) }
|
||||
v.extend(3..10);
|
||||
for i in 3..10 { w.push(i) }
|
||||
|
||||
assert_eq!(v, w);
|
||||
}
|
||||
@ -2055,7 +2055,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let v: Vec<int> = vec!();
|
||||
let w = vec!(1i, 2, 3);
|
||||
let w = vec!(1, 2, 3);
|
||||
|
||||
assert_eq!(v, v.clone());
|
||||
|
||||
@ -2068,8 +2068,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clone_from() {
|
||||
let mut v = vec!();
|
||||
let three = vec!(box 1i, box 2, box 3);
|
||||
let two = vec!(box 4i, box 5);
|
||||
let three = vec!(box 1, box 2, box 3);
|
||||
let two = vec!(box 4, box 5);
|
||||
// zero, long
|
||||
v.clone_from(&three);
|
||||
assert_eq!(v, three);
|
||||
@ -2128,14 +2128,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_partition() {
|
||||
assert_eq!(vec![].into_iter().partition(|x: &int| *x < 3), (vec![], vec![]));
|
||||
assert_eq!(vec![1i, 2, 3].into_iter().partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
|
||||
assert_eq!(vec![1i, 2, 3].into_iter().partition(|x: &int| *x < 2), (vec![1], vec![2, 3]));
|
||||
assert_eq!(vec![1i, 2, 3].into_iter().partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));
|
||||
assert_eq!(vec![1, 2, 3].into_iter().partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
|
||||
assert_eq!(vec![1, 2, 3].into_iter().partition(|x: &int| *x < 2), (vec![1], vec![2, 3]));
|
||||
assert_eq!(vec![1, 2, 3].into_iter().partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zip_unzip() {
|
||||
let z1 = vec![(1i, 4i), (2, 5), (3, 6)];
|
||||
let z1 = vec![(1, 4), (2, 5), (3, 6)];
|
||||
|
||||
let (left, right): (Vec<_>, Vec<_>) = z1.iter().map(|&x| x).unzip();
|
||||
|
||||
@ -2148,13 +2148,13 @@ mod tests {
|
||||
fn test_unsafe_ptrs() {
|
||||
unsafe {
|
||||
// Test on-stack copy-from-buf.
|
||||
let a = [1i, 2, 3];
|
||||
let a = [1, 2, 3];
|
||||
let ptr = a.as_ptr();
|
||||
let b = Vec::from_raw_buf(ptr, 3u);
|
||||
assert_eq!(b, vec![1, 2, 3]);
|
||||
|
||||
// Test on-heap copy-from-buf.
|
||||
let c = vec![1i, 2, 3, 4, 5];
|
||||
let c = vec![1, 2, 3, 4, 5];
|
||||
let ptr = c.as_ptr();
|
||||
let d = Vec::from_raw_buf(ptr, 5u);
|
||||
assert_eq!(d, vec![1, 2, 3, 4, 5]);
|
||||
@ -2198,14 +2198,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_index() {
|
||||
let vec = vec!(1i, 2, 3);
|
||||
let vec = vec!(1, 2, 3);
|
||||
assert!(vec[1] == 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_index_out_of_bounds() {
|
||||
let vec = vec!(1i, 2, 3);
|
||||
let vec = vec!(1, 2, 3);
|
||||
let _ = vec[3];
|
||||
}
|
||||
|
||||
@ -2273,7 +2273,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_map_in_place() {
|
||||
let v = vec![0u, 1, 2];
|
||||
assert_eq!(v.map_in_place(|i: uint| i as int - 1), [-1i, 0, 1]);
|
||||
assert_eq!(v.map_in_place(|i: uint| i as int - 1), [-1, 0, 1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -768,7 +768,7 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_get_mut() {
|
||||
let mut m = VecMap::new();
|
||||
assert!(m.insert(1, 12i).is_none());
|
||||
assert!(m.insert(1, 12).is_none());
|
||||
assert!(m.insert(2, 8).is_none());
|
||||
assert!(m.insert(5, 14).is_none());
|
||||
let new = 100;
|
||||
@ -783,7 +783,7 @@ mod test_map {
|
||||
let mut map = VecMap::new();
|
||||
assert_eq!(map.len(), 0);
|
||||
assert!(map.is_empty());
|
||||
assert!(map.insert(5, 20i).is_none());
|
||||
assert!(map.insert(5, 20).is_none());
|
||||
assert_eq!(map.len(), 1);
|
||||
assert!(!map.is_empty());
|
||||
assert!(map.insert(11, 12).is_none());
|
||||
@ -797,7 +797,7 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_clear() {
|
||||
let mut map = VecMap::new();
|
||||
assert!(map.insert(5, 20i).is_none());
|
||||
assert!(map.insert(5, 20).is_none());
|
||||
assert!(map.insert(11, 12).is_none());
|
||||
assert!(map.insert(14, 22).is_none());
|
||||
map.clear();
|
||||
@ -810,15 +810,15 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_insert() {
|
||||
let mut m = VecMap::new();
|
||||
assert_eq!(m.insert(1, 2i), None);
|
||||
assert_eq!(m.insert(1, 3i), Some(2));
|
||||
assert_eq!(m.insert(1, 4i), Some(3));
|
||||
assert_eq!(m.insert(1, 2), None);
|
||||
assert_eq!(m.insert(1, 3), Some(2));
|
||||
assert_eq!(m.insert(1, 4), Some(3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove() {
|
||||
let mut m = VecMap::new();
|
||||
m.insert(1, 2i);
|
||||
m.insert(1, 2);
|
||||
assert_eq!(m.remove(&1), Some(2));
|
||||
assert_eq!(m.remove(&1), None);
|
||||
}
|
||||
@ -853,7 +853,7 @@ mod test_map {
|
||||
fn test_iterator() {
|
||||
let mut m = VecMap::new();
|
||||
|
||||
assert!(m.insert(0, 1i).is_none());
|
||||
assert!(m.insert(0, 1).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(m.insert(3, 5).is_none());
|
||||
assert!(m.insert(6, 10).is_none());
|
||||
@ -878,7 +878,7 @@ mod test_map {
|
||||
fn test_iterator_size_hints() {
|
||||
let mut m = VecMap::new();
|
||||
|
||||
assert!(m.insert(0, 1i).is_none());
|
||||
assert!(m.insert(0, 1).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(m.insert(3, 5).is_none());
|
||||
assert!(m.insert(6, 10).is_none());
|
||||
@ -894,7 +894,7 @@ mod test_map {
|
||||
fn test_mut_iterator() {
|
||||
let mut m = VecMap::new();
|
||||
|
||||
assert!(m.insert(0, 1i).is_none());
|
||||
assert!(m.insert(0, 1).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(m.insert(3, 5).is_none());
|
||||
assert!(m.insert(6, 10).is_none());
|
||||
@ -917,7 +917,7 @@ mod test_map {
|
||||
fn test_rev_iterator() {
|
||||
let mut m = VecMap::new();
|
||||
|
||||
assert!(m.insert(0, 1i).is_none());
|
||||
assert!(m.insert(0, 1).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(m.insert(3, 5).is_none());
|
||||
assert!(m.insert(6, 10).is_none());
|
||||
@ -936,7 +936,7 @@ mod test_map {
|
||||
fn test_mut_rev_iterator() {
|
||||
let mut m = VecMap::new();
|
||||
|
||||
assert!(m.insert(0, 1i).is_none());
|
||||
assert!(m.insert(0, 1).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(m.insert(3, 5).is_none());
|
||||
assert!(m.insert(6, 10).is_none());
|
||||
@ -958,13 +958,13 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_move_iter() {
|
||||
let mut m = VecMap::new();
|
||||
m.insert(1, box 2i);
|
||||
m.insert(1, box 2);
|
||||
let mut called = false;
|
||||
for (k, v) in m.into_iter() {
|
||||
assert!(!called);
|
||||
called = true;
|
||||
assert_eq!(k, 1);
|
||||
assert_eq!(v, box 2i);
|
||||
assert_eq!(v, box 2);
|
||||
}
|
||||
assert!(called);
|
||||
}
|
||||
@ -987,8 +987,8 @@ mod test_map {
|
||||
let mut map = VecMap::new();
|
||||
let empty = VecMap::<int>::new();
|
||||
|
||||
map.insert(1, 2i);
|
||||
map.insert(3, 4i);
|
||||
map.insert(1, 2);
|
||||
map.insert(3, 4);
|
||||
|
||||
let map_str = format!("{:?}", map);
|
||||
assert!(map_str == "VecMap {1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
|
||||
@ -1012,9 +1012,9 @@ mod test_map {
|
||||
let mut b = VecMap::new();
|
||||
|
||||
assert!(a == b);
|
||||
assert!(a.insert(0, 5i).is_none());
|
||||
assert!(a.insert(0, 5).is_none());
|
||||
assert!(a != b);
|
||||
assert!(b.insert(0, 4i).is_none());
|
||||
assert!(b.insert(0, 4).is_none());
|
||||
assert!(a != b);
|
||||
assert!(a.insert(5, 19).is_none());
|
||||
assert!(a != b);
|
||||
@ -1034,7 +1034,7 @@ mod test_map {
|
||||
let mut b = VecMap::new();
|
||||
|
||||
assert!(!(a < b) && !(b < a));
|
||||
assert!(b.insert(2u, 5i).is_none());
|
||||
assert!(b.insert(2u, 5).is_none());
|
||||
assert!(a < b);
|
||||
assert!(a.insert(2, 7).is_none());
|
||||
assert!(!(a < b) && b < a);
|
||||
@ -1052,7 +1052,7 @@ mod test_map {
|
||||
let mut b = VecMap::new();
|
||||
|
||||
assert!(a <= b && a >= b);
|
||||
assert!(a.insert(1u, 1i).is_none());
|
||||
assert!(a.insert(1u, 1).is_none());
|
||||
assert!(a > b && a >= b);
|
||||
assert!(b < a && b <= a);
|
||||
assert!(b.insert(2, 2).is_none());
|
||||
|
@ -123,7 +123,7 @@ fn any_fixed_vec() {
|
||||
#[bench]
|
||||
fn bench_downcast_ref(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let mut x = 0i;
|
||||
let mut x = 0;
|
||||
let mut y = &mut x as &mut Any;
|
||||
test::black_box(&mut y);
|
||||
test::black_box(y.downcast_ref::<int>() == Some(&0));
|
||||
|
@ -14,14 +14,14 @@ use std::mem::drop;
|
||||
|
||||
#[test]
|
||||
fn smoketest_cell() {
|
||||
let x = Cell::new(10i);
|
||||
let x = Cell::new(10);
|
||||
assert!(x == Cell::new(10));
|
||||
assert!(x.get() == 10);
|
||||
x.set(20);
|
||||
assert!(x == Cell::new(20));
|
||||
assert!(x.get() == 20);
|
||||
|
||||
let y = Cell::new((30i, 40i));
|
||||
let y = Cell::new((30, 40));
|
||||
assert!(y == Cell::new((30, 40)));
|
||||
assert!(y.get() == (30, 40));
|
||||
}
|
||||
@ -50,35 +50,35 @@ fn ref_and_refmut_have_sensible_show() {
|
||||
|
||||
#[test]
|
||||
fn double_imm_borrow() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
let _b1 = x.borrow();
|
||||
x.borrow();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_mut_then_imm_borrow() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
let _b1 = x.borrow_mut();
|
||||
assert!(x.try_borrow().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_imm_then_borrow_mut() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
let _b1 = x.borrow();
|
||||
assert!(x.try_borrow_mut().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_double_borrow_mut() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
let _b1 = x.borrow_mut();
|
||||
assert!(x.try_borrow_mut().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn imm_release_borrow_mut() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
{
|
||||
let _b1 = x.borrow();
|
||||
}
|
||||
@ -87,7 +87,7 @@ fn imm_release_borrow_mut() {
|
||||
|
||||
#[test]
|
||||
fn mut_release_borrow_mut() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
{
|
||||
let _b1 = x.borrow_mut();
|
||||
}
|
||||
@ -96,7 +96,7 @@ fn mut_release_borrow_mut() {
|
||||
|
||||
#[test]
|
||||
fn double_borrow_single_release_no_borrow_mut() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
let _b1 = x.borrow();
|
||||
{
|
||||
let _b2 = x.borrow();
|
||||
@ -107,7 +107,7 @@ fn double_borrow_single_release_no_borrow_mut() {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn discard_doesnt_unborrow() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
let _b = x.borrow();
|
||||
let _ = _b;
|
||||
let _b = x.borrow_mut();
|
||||
@ -115,7 +115,7 @@ fn discard_doesnt_unborrow() {
|
||||
|
||||
#[test]
|
||||
fn clone_ref_updates_flag() {
|
||||
let x = RefCell::new(0i);
|
||||
let x = RefCell::new(0);
|
||||
{
|
||||
let b1 = x.borrow();
|
||||
assert!(x.try_borrow_mut().is_none());
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#[test]
|
||||
fn test_borrowed_clone() {
|
||||
let x = 5i;
|
||||
let x = 5;
|
||||
let y: &int = &x;
|
||||
let z: &int = (&y).clone();
|
||||
assert_eq!(*z, 5);
|
||||
@ -18,8 +18,8 @@ fn test_borrowed_clone() {
|
||||
|
||||
#[test]
|
||||
fn test_clone_from() {
|
||||
let a = box 5i;
|
||||
let mut b = box 10i;
|
||||
let a = box 5;
|
||||
let mut b = box 10;
|
||||
b.clone_from(&a);
|
||||
assert_eq!(*b, 5);
|
||||
}
|
||||
|
@ -13,20 +13,20 @@ use core::cmp::Ordering::{Less, Greater, Equal};
|
||||
|
||||
#[test]
|
||||
fn test_int_totalord() {
|
||||
assert_eq!(5i.cmp(&10), Less);
|
||||
assert_eq!(10i.cmp(&5), Greater);
|
||||
assert_eq!(5i.cmp(&5), Equal);
|
||||
assert_eq!((-5i).cmp(&12), Less);
|
||||
assert_eq!(12i.cmp(&-5), Greater);
|
||||
assert_eq!(5.cmp(&10), Less);
|
||||
assert_eq!(10.cmp(&5), Greater);
|
||||
assert_eq!(5.cmp(&5), Equal);
|
||||
assert_eq!((-5).cmp(&12), Less);
|
||||
assert_eq!(12.cmp(&-5), Greater);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mut_int_totalord() {
|
||||
assert_eq!((&mut 5i).cmp(&&mut 10), Less);
|
||||
assert_eq!((&mut 10i).cmp(&&mut 5), Greater);
|
||||
assert_eq!((&mut 5i).cmp(&&mut 5), Equal);
|
||||
assert_eq!((&mut -5i).cmp(&&mut 12), Less);
|
||||
assert_eq!((&mut 12i).cmp(&&mut -5), Greater);
|
||||
assert_eq!((&mut 5).cmp(&&mut 10), Less);
|
||||
assert_eq!((&mut 10).cmp(&&mut 5), Greater);
|
||||
assert_eq!((&mut 5).cmp(&&mut 5), Equal);
|
||||
assert_eq!((&mut -5).cmp(&&mut 12), Less);
|
||||
assert_eq!((&mut 12).cmp(&&mut -5), Greater);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -47,11 +47,11 @@ fn test_partial_min() {
|
||||
use core::f64::NAN;
|
||||
let data_integer = [
|
||||
// a, b, result
|
||||
(0i, 0i, Some(0i)),
|
||||
(1i, 0i, Some(0i)),
|
||||
(0i, 1i, Some(0i)),
|
||||
(-1i, 0i, Some(-1i)),
|
||||
(0i, -1i, Some(-1i))
|
||||
(0, 0, Some(0)),
|
||||
(1, 0, Some(0)),
|
||||
(0, 1, Some(0)),
|
||||
(-1, 0, Some(-1)),
|
||||
(0, -1, Some(-1))
|
||||
];
|
||||
|
||||
let data_float = [
|
||||
@ -80,11 +80,11 @@ fn test_partial_max() {
|
||||
use core::f64::NAN;
|
||||
let data_integer = [
|
||||
// a, b, result
|
||||
(0i, 0i, Some(0i)),
|
||||
(1i, 0i, Some(1i)),
|
||||
(0i, 1i, Some(1i)),
|
||||
(-1i, 0i, Some(0i)),
|
||||
(0i, -1i, Some(0i))
|
||||
(0, 0, Some(0)),
|
||||
(1, 0, Some(1)),
|
||||
(0, 1, Some(1)),
|
||||
(-1, 0, Some(0)),
|
||||
(0, -1, Some(0))
|
||||
];
|
||||
|
||||
let data_float = [
|
||||
|
@ -15,7 +15,7 @@ use std::thread::Thread;
|
||||
|
||||
#[test]
|
||||
fn test_success() {
|
||||
let mut i = 0i;
|
||||
let mut i = 0;
|
||||
try_finally(
|
||||
&mut i, (),
|
||||
|i, ()| {
|
||||
@ -32,7 +32,7 @@ fn test_success() {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_fail() {
|
||||
let mut i = 0i;
|
||||
let mut i = 0;
|
||||
try_finally(
|
||||
&mut i, (),
|
||||
|i, ()| {
|
||||
@ -47,7 +47,7 @@ fn test_fail() {
|
||||
|
||||
#[test]
|
||||
fn test_retval() {
|
||||
let mut closure = |&mut:| 10i;
|
||||
let mut closure = |&mut:| 10;
|
||||
let i = closure.finally(|| { });
|
||||
assert_eq!(i, 10);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ fn test_writer_hasher() {
|
||||
assert_eq!(hash(&5i16), 5);
|
||||
assert_eq!(hash(&5i32), 5);
|
||||
assert_eq!(hash(&5i64), 5);
|
||||
assert_eq!(hash(&5i), 5);
|
||||
assert_eq!(hash(&5), 5);
|
||||
|
||||
assert_eq!(hash(&false), 0);
|
||||
assert_eq!(hash(&true), 1);
|
||||
@ -76,12 +76,12 @@ fn test_writer_hasher() {
|
||||
// FIXME (#18248) Add tests for hashing Rc<str> and Rc<[T]>
|
||||
|
||||
unsafe {
|
||||
let ptr: *const int = mem::transmute(5i);
|
||||
let ptr: *const int = mem::transmute(5);
|
||||
assert_eq!(hash(&ptr), 5);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let ptr: *mut int = mem::transmute(5i);
|
||||
let ptr: *mut int = mem::transmute(5);
|
||||
assert_eq!(hash(&ptr), 5);
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ use test::Bencher;
|
||||
#[test]
|
||||
fn test_lt() {
|
||||
let empty: [int; 0] = [];
|
||||
let xs = [1i,2,3];
|
||||
let ys = [1i,2,0];
|
||||
let xs = [1,2,3];
|
||||
let ys = [1,2,0];
|
||||
|
||||
assert!(!lt(xs.iter(), ys.iter()));
|
||||
assert!(!le(xs.iter(), ys.iter()));
|
||||
@ -64,15 +64,15 @@ fn test_lt() {
|
||||
|
||||
#[test]
|
||||
fn test_multi_iter() {
|
||||
let xs = [1i,2,3,4];
|
||||
let ys = [4i,3,2,1];
|
||||
let xs = [1,2,3,4];
|
||||
let ys = [4,3,2,1];
|
||||
assert!(eq(xs.iter(), ys.iter().rev()));
|
||||
assert!(lt(xs.iter(), xs.iter().skip(2)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_counter_from_iter() {
|
||||
let it = count(0i, 5).take(10);
|
||||
let it = count(0, 5).take(10);
|
||||
let xs: Vec<int> = FromIterator::from_iter(it);
|
||||
assert!(xs == vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
|
||||
}
|
||||
@ -304,7 +304,7 @@ fn test_cycle() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_nth() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4];
|
||||
for i in 0u..v.len() {
|
||||
assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
|
||||
}
|
||||
@ -313,14 +313,14 @@ fn test_iterator_nth() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_last() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4];
|
||||
assert_eq!(v.iter().last().unwrap(), &4);
|
||||
assert_eq!(v[..1].iter().last().unwrap(), &0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator_len() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[..4].iter().count(), 4);
|
||||
assert_eq!(v[..10].iter().count(), 10);
|
||||
assert_eq!(v[..0].iter().count(), 0);
|
||||
@ -328,7 +328,7 @@ fn test_iterator_len() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_sum() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[..4].iter().map(|&x| x).sum(), 6);
|
||||
assert_eq!(v.iter().map(|&x| x).sum(), 55);
|
||||
assert_eq!(v[..0].iter().map(|&x| x).sum(), 0);
|
||||
@ -336,7 +336,7 @@ fn test_iterator_sum() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_product() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[..4].iter().map(|&x| x).product(), 0);
|
||||
assert_eq!(v[1..5].iter().map(|&x| x).product(), 24);
|
||||
assert_eq!(v[..0].iter().map(|&x| x).product(), 1);
|
||||
@ -344,7 +344,7 @@ fn test_iterator_product() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_max() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[..4].iter().map(|&x| x).max(), Some(3));
|
||||
assert_eq!(v.iter().map(|&x| x).max(), Some(10));
|
||||
assert_eq!(v[..0].iter().map(|&x| x).max(), None);
|
||||
@ -352,7 +352,7 @@ fn test_iterator_max() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_min() {
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
assert_eq!(v[..4].iter().map(|&x| x).min(), Some(0));
|
||||
assert_eq!(v.iter().map(|&x| x).min(), Some(0));
|
||||
assert_eq!(v[..0].iter().map(|&x| x).min(), None);
|
||||
@ -360,9 +360,9 @@ fn test_iterator_min() {
|
||||
|
||||
#[test]
|
||||
fn test_iterator_size_hint() {
|
||||
let c = count(0i, 1);
|
||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
let v2 = &[10i, 11, 12];
|
||||
let c = count(0, 1);
|
||||
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
let v2 = &[10, 11, 12];
|
||||
let vi = v.iter();
|
||||
|
||||
assert_eq!(c.size_hint(), (uint::MAX, None));
|
||||
@ -375,10 +375,10 @@ fn test_iterator_size_hint() {
|
||||
assert_eq!(c.enumerate().size_hint(), (uint::MAX, None));
|
||||
assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None));
|
||||
assert_eq!(c.zip(vi).size_hint(), (10, Some(10)));
|
||||
assert_eq!(c.scan(0i, |_,_| Some(0i)).size_hint(), (0, None));
|
||||
assert_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None));
|
||||
assert_eq!(c.filter(|_| false).size_hint(), (0, None));
|
||||
assert_eq!(c.map(|_| 0i).size_hint(), (uint::MAX, None));
|
||||
assert_eq!(c.filter_map(|_| Some(0i)).size_hint(), (0, None));
|
||||
assert_eq!(c.map(|_| 0).size_hint(), (uint::MAX, None));
|
||||
assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
|
||||
|
||||
assert_eq!(vi.take(5).size_hint(), (5, Some(5)));
|
||||
assert_eq!(vi.take(12).size_hint(), (10, Some(10)));
|
||||
@ -389,22 +389,22 @@ fn test_iterator_size_hint() {
|
||||
assert_eq!(vi.enumerate().size_hint(), (10, Some(10)));
|
||||
assert_eq!(vi.chain(v2.iter()).size_hint(), (13, Some(13)));
|
||||
assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3)));
|
||||
assert_eq!(vi.scan(0i, |_,_| Some(0i)).size_hint(), (0, Some(10)));
|
||||
assert_eq!(vi.scan(0, |_,_| Some(0)).size_hint(), (0, Some(10)));
|
||||
assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10)));
|
||||
assert_eq!(vi.map(|&i| i+1).size_hint(), (10, Some(10)));
|
||||
assert_eq!(vi.filter_map(|_| Some(0i)).size_hint(), (0, Some(10)));
|
||||
assert_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_collect() {
|
||||
let a = vec![1i, 2, 3, 4, 5];
|
||||
let a = vec![1, 2, 3, 4, 5];
|
||||
let b: Vec<int> = a.iter().map(|&x| x).collect();
|
||||
assert!(a == b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_all() {
|
||||
let v: Box<[int]> = box [1i, 2, 3, 4, 5];
|
||||
let v: Box<[int]> = box [1, 2, 3, 4, 5];
|
||||
assert!(v.iter().all(|&x| x < 10));
|
||||
assert!(!v.iter().all(|&x| x % 2 == 0));
|
||||
assert!(!v.iter().all(|&x| x > 100));
|
||||
@ -413,7 +413,7 @@ fn test_all() {
|
||||
|
||||
#[test]
|
||||
fn test_any() {
|
||||
let v: Box<[int]> = box [1i, 2, 3, 4, 5];
|
||||
let v: Box<[int]> = box [1, 2, 3, 4, 5];
|
||||
assert!(v.iter().any(|&x| x < 10));
|
||||
assert!(v.iter().any(|&x| x % 2 == 0));
|
||||
assert!(!v.iter().any(|&x| x > 100));
|
||||
@ -422,7 +422,7 @@ fn test_any() {
|
||||
|
||||
#[test]
|
||||
fn test_find() {
|
||||
let v: &[int] = &[1i, 3, 9, 27, 103, 14, 11];
|
||||
let v: &[int] = &[1, 3, 9, 27, 103, 14, 11];
|
||||
assert_eq!(*v.iter().find(|&&x| x & 1 == 0).unwrap(), 14);
|
||||
assert_eq!(*v.iter().find(|&&x| x % 3 == 0).unwrap(), 3);
|
||||
assert!(v.iter().find(|&&x| x % 12 == 0).is_none());
|
||||
@ -430,7 +430,7 @@ fn test_find() {
|
||||
|
||||
#[test]
|
||||
fn test_position() {
|
||||
let v = &[1i, 3, 9, 27, 103, 14, 11];
|
||||
let v = &[1, 3, 9, 27, 103, 14, 11];
|
||||
assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5);
|
||||
assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1);
|
||||
assert!(v.iter().position(|x| *x % 12 == 0).is_none());
|
||||
@ -438,7 +438,7 @@ fn test_position() {
|
||||
|
||||
#[test]
|
||||
fn test_count() {
|
||||
let xs = &[1i, 2, 2, 1, 5, 9, 0, 2];
|
||||
let xs = &[1, 2, 2, 1, 5, 9, 0, 2];
|
||||
assert_eq!(xs.iter().filter(|x| **x == 2).count(), 3);
|
||||
assert_eq!(xs.iter().filter(|x| **x == 5).count(), 1);
|
||||
assert_eq!(xs.iter().filter(|x| **x == 95).count(), 0);
|
||||
@ -446,19 +446,19 @@ fn test_count() {
|
||||
|
||||
#[test]
|
||||
fn test_max_by() {
|
||||
let xs: &[int] = &[-3i, 0, 1, 5, -10];
|
||||
let xs: &[int] = &[-3, 0, 1, 5, -10];
|
||||
assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_min_by() {
|
||||
let xs: &[int] = &[-3i, 0, 1, 5, -10];
|
||||
let xs: &[int] = &[-3, 0, 1, 5, -10];
|
||||
assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_by_ref() {
|
||||
let mut xs = 0i..10;
|
||||
let mut xs = 0..10;
|
||||
// sum the first five values
|
||||
let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b);
|
||||
assert_eq!(partial_sum, 10);
|
||||
@ -467,7 +467,7 @@ fn test_by_ref() {
|
||||
|
||||
#[test]
|
||||
fn test_rev() {
|
||||
let xs = [2i, 4, 6, 8, 10, 12, 14, 16];
|
||||
let xs = [2, 4, 6, 8, 10, 12, 14, 16];
|
||||
let mut it = xs.iter();
|
||||
it.next();
|
||||
it.next();
|
||||
@ -494,7 +494,7 @@ fn test_cloned() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_map() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6];
|
||||
let xs = [1, 2, 3, 4, 5, 6];
|
||||
let mut it = xs.iter().map(|&x| x * -1);
|
||||
assert_eq!(it.next(), Some(-1));
|
||||
assert_eq!(it.next(), Some(-2));
|
||||
@ -507,7 +507,7 @@ fn test_double_ended_map() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_enumerate() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6];
|
||||
let xs = [1, 2, 3, 4, 5, 6];
|
||||
let mut it = xs.iter().map(|&x| x).enumerate();
|
||||
assert_eq!(it.next(), Some((0, 1)));
|
||||
assert_eq!(it.next(), Some((1, 2)));
|
||||
@ -520,8 +520,8 @@ fn test_double_ended_enumerate() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_zip() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6];
|
||||
let ys = [1i, 2, 3, 7];
|
||||
let xs = [1, 2, 3, 4, 5, 6];
|
||||
let ys = [1, 2, 3, 7];
|
||||
let a = xs.iter().map(|&x| x);
|
||||
let b = ys.iter().map(|&x| x);
|
||||
let mut it = a.zip(b);
|
||||
@ -534,7 +534,7 @@ fn test_double_ended_zip() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_filter() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6];
|
||||
let xs = [1, 2, 3, 4, 5, 6];
|
||||
let mut it = xs.iter().filter(|&x| *x & 1 == 0);
|
||||
assert_eq!(it.next_back().unwrap(), &6);
|
||||
assert_eq!(it.next_back().unwrap(), &4);
|
||||
@ -544,7 +544,7 @@ fn test_double_ended_filter() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_filter_map() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6];
|
||||
let xs = [1, 2, 3, 4, 5, 6];
|
||||
let mut it = xs.iter().filter_map(|&x| if x & 1 == 0 { Some(x * 2) } else { None });
|
||||
assert_eq!(it.next_back().unwrap(), 12);
|
||||
assert_eq!(it.next_back().unwrap(), 8);
|
||||
@ -554,8 +554,8 @@ fn test_double_ended_filter_map() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_chain() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let ys = [7i, 9, 11];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
let ys = [7, 9, 11];
|
||||
let mut it = xs.iter().chain(ys.iter()).rev();
|
||||
assert_eq!(it.next().unwrap(), &11);
|
||||
assert_eq!(it.next().unwrap(), &9);
|
||||
@ -572,7 +572,7 @@ fn test_double_ended_chain() {
|
||||
fn test_rposition() {
|
||||
fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
|
||||
fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
|
||||
let v = [(0i, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
|
||||
let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
|
||||
|
||||
assert_eq!(v.iter().rposition(f), Some(3u));
|
||||
assert!(v.iter().rposition(g).is_none());
|
||||
@ -581,9 +581,9 @@ fn test_rposition() {
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_rposition_panic() {
|
||||
let v = [(box 0i, box 0i), (box 0i, box 0i),
|
||||
(box 0i, box 0i), (box 0i, box 0i)];
|
||||
let mut i = 0i;
|
||||
let v = [(box 0, box 0), (box 0, box 0),
|
||||
(box 0, box 0), (box 0, box 0)];
|
||||
let mut i = 0;
|
||||
v.iter().rposition(|_elt| {
|
||||
if i == 2 {
|
||||
panic!()
|
||||
@ -635,8 +635,8 @@ fn test_double_ended_flat_map() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_chain() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let ys = [7i, 9, 11];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
let ys = [7, 9, 11];
|
||||
let mut it = xs.iter().chain(ys.iter());
|
||||
assert_eq!(it.idx(0).unwrap(), &1);
|
||||
assert_eq!(it.idx(5).unwrap(), &7);
|
||||
@ -656,13 +656,13 @@ fn test_random_access_chain() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_enumerate() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
check_randacc_iter(xs.iter().enumerate(), xs.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_random_access_rev() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
check_randacc_iter(xs.iter().rev(), xs.len());
|
||||
let mut it = xs.iter().rev();
|
||||
it.next();
|
||||
@ -673,14 +673,14 @@ fn test_random_access_rev() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_zip() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let ys = [7i, 9, 11];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
let ys = [7, 9, 11];
|
||||
check_randacc_iter(xs.iter().zip(ys.iter()), cmp::min(xs.len(), ys.len()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_random_access_take() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
let empty: &[int] = &[];
|
||||
check_randacc_iter(xs.iter().take(3), 3);
|
||||
check_randacc_iter(xs.iter().take(20), xs.len());
|
||||
@ -690,7 +690,7 @@ fn test_random_access_take() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_skip() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
let empty: &[int] = &[];
|
||||
check_randacc_iter(xs.iter().skip(2), xs.len() - 2);
|
||||
check_randacc_iter(empty.iter().skip(2), 0);
|
||||
@ -698,7 +698,7 @@ fn test_random_access_skip() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_inspect() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
|
||||
// test .map and .inspect that don't implement Clone
|
||||
let mut it = xs.iter().inspect(|_| {});
|
||||
@ -711,7 +711,7 @@ fn test_random_access_inspect() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_map() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
|
||||
let mut it = xs.iter().map(|x| *x);
|
||||
assert_eq!(xs.len(), it.indexable());
|
||||
@ -722,7 +722,7 @@ fn test_random_access_map() {
|
||||
|
||||
#[test]
|
||||
fn test_random_access_cycle() {
|
||||
let xs = [1i, 2, 3, 4, 5];
|
||||
let xs = [1, 2, 3, 4, 5];
|
||||
let empty: &[int] = &[];
|
||||
check_randacc_iter(xs.iter().cycle().take(27), 27);
|
||||
check_randacc_iter(empty.iter().cycle(), 0);
|
||||
@ -730,8 +730,8 @@ fn test_random_access_cycle() {
|
||||
|
||||
#[test]
|
||||
fn test_double_ended_range() {
|
||||
assert!((11i..14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]);
|
||||
for _ in (10i..0).rev() {
|
||||
assert!((11..14).rev().collect::<Vec<int>>() == vec![13, 12, 11]);
|
||||
for _ in (10..0).rev() {
|
||||
panic!("unreachable");
|
||||
}
|
||||
|
||||
@ -743,73 +743,73 @@ fn test_double_ended_range() {
|
||||
|
||||
#[test]
|
||||
fn test_range() {
|
||||
assert!((0i..5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]);
|
||||
assert!((-10i..-1).collect::<Vec<int>>() ==
|
||||
assert!((0..5).collect::<Vec<int>>() == vec![0, 1, 2, 3, 4]);
|
||||
assert!((-10..-1).collect::<Vec<int>>() ==
|
||||
vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]);
|
||||
assert!((0i..5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]);
|
||||
assert_eq!((200i..-5).count(), 0);
|
||||
assert_eq!((200i..-5).rev().count(), 0);
|
||||
assert_eq!((200i..200).count(), 0);
|
||||
assert_eq!((200i..200).rev().count(), 0);
|
||||
assert!((0..5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]);
|
||||
assert_eq!((200..-5).count(), 0);
|
||||
assert_eq!((200..-5).rev().count(), 0);
|
||||
assert_eq!((200..200).count(), 0);
|
||||
assert_eq!((200..200).rev().count(), 0);
|
||||
|
||||
assert_eq!((0i..100).size_hint(), (100, Some(100)));
|
||||
assert_eq!((0..100).size_hint(), (100, Some(100)));
|
||||
// this test is only meaningful when sizeof uint < sizeof u64
|
||||
assert_eq!((uint::MAX - 1..uint::MAX).size_hint(), (1, Some(1)));
|
||||
assert_eq!((-10i..-1).size_hint(), (9, Some(9)));
|
||||
assert_eq!((-10..-1).size_hint(), (9, Some(9)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_inclusive() {
|
||||
assert!(range_inclusive(0i, 5).collect::<Vec<int>>() ==
|
||||
vec![0i, 1, 2, 3, 4, 5]);
|
||||
assert!(range_inclusive(0i, 5).rev().collect::<Vec<int>>() ==
|
||||
vec![5i, 4, 3, 2, 1, 0]);
|
||||
assert_eq!(range_inclusive(200i, -5).count(), 0);
|
||||
assert_eq!(range_inclusive(200i, -5).rev().count(), 0);
|
||||
assert!(range_inclusive(200i, 200).collect::<Vec<int>>() == vec![200]);
|
||||
assert!(range_inclusive(200i, 200).rev().collect::<Vec<int>>() == vec![200]);
|
||||
assert!(range_inclusive(0, 5).collect::<Vec<int>>() ==
|
||||
vec![0, 1, 2, 3, 4, 5]);
|
||||
assert!(range_inclusive(0, 5).rev().collect::<Vec<int>>() ==
|
||||
vec![5, 4, 3, 2, 1, 0]);
|
||||
assert_eq!(range_inclusive(200, -5).count(), 0);
|
||||
assert_eq!(range_inclusive(200, -5).rev().count(), 0);
|
||||
assert!(range_inclusive(200, 200).collect::<Vec<int>>() == vec![200]);
|
||||
assert!(range_inclusive(200, 200).rev().collect::<Vec<int>>() == vec![200]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_step() {
|
||||
assert!(range_step(0i, 20, 5).collect::<Vec<int>>() ==
|
||||
assert!(range_step(0, 20, 5).collect::<Vec<int>>() ==
|
||||
vec![0, 5, 10, 15]);
|
||||
assert!(range_step(20i, 0, -5).collect::<Vec<int>>() ==
|
||||
assert!(range_step(20, 0, -5).collect::<Vec<int>>() ==
|
||||
vec![20, 15, 10, 5]);
|
||||
assert!(range_step(20i, 0, -6).collect::<Vec<int>>() ==
|
||||
assert!(range_step(20, 0, -6).collect::<Vec<int>>() ==
|
||||
vec![20, 14, 8, 2]);
|
||||
assert!(range_step(200u8, 255, 50).collect::<Vec<u8>>() ==
|
||||
vec![200u8, 250]);
|
||||
assert!(range_step(200i, -5, 1).collect::<Vec<int>>() == vec![]);
|
||||
assert!(range_step(200i, 200, 1).collect::<Vec<int>>() == vec![]);
|
||||
assert!(range_step(200, -5, 1).collect::<Vec<int>>() == vec![]);
|
||||
assert!(range_step(200, 200, 1).collect::<Vec<int>>() == vec![]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_step_inclusive() {
|
||||
assert!(range_step_inclusive(0i, 20, 5).collect::<Vec<int>>() ==
|
||||
assert!(range_step_inclusive(0, 20, 5).collect::<Vec<int>>() ==
|
||||
vec![0, 5, 10, 15, 20]);
|
||||
assert!(range_step_inclusive(20i, 0, -5).collect::<Vec<int>>() ==
|
||||
assert!(range_step_inclusive(20, 0, -5).collect::<Vec<int>>() ==
|
||||
vec![20, 15, 10, 5, 0]);
|
||||
assert!(range_step_inclusive(20i, 0, -6).collect::<Vec<int>>() ==
|
||||
assert!(range_step_inclusive(20, 0, -6).collect::<Vec<int>>() ==
|
||||
vec![20, 14, 8, 2]);
|
||||
assert!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>() ==
|
||||
vec![200u8, 250]);
|
||||
assert!(range_step_inclusive(200i, -5, 1).collect::<Vec<int>>() ==
|
||||
assert!(range_step_inclusive(200, -5, 1).collect::<Vec<int>>() ==
|
||||
vec![]);
|
||||
assert!(range_step_inclusive(200i, 200, 1).collect::<Vec<int>>() ==
|
||||
assert!(range_step_inclusive(200, 200, 1).collect::<Vec<int>>() ==
|
||||
vec![200]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reverse() {
|
||||
let mut ys = [1i, 2, 3, 4, 5];
|
||||
let mut ys = [1, 2, 3, 4, 5];
|
||||
ys.iter_mut().reverse_in_place();
|
||||
assert!(ys == [5, 4, 3, 2, 1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_peekable_is_empty() {
|
||||
let a = [1i];
|
||||
let a = [1];
|
||||
let mut it = a.iter().peekable();
|
||||
assert!( !it.is_empty() );
|
||||
it.next();
|
||||
@ -821,16 +821,16 @@ fn test_min_max() {
|
||||
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));
|
||||
}
|
||||
|
||||
@ -839,10 +839,10 @@ fn test_min_max_result() {
|
||||
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,2);
|
||||
let r = MinMax(1,2);
|
||||
assert_eq!(r.into_option(), Some((1,2)));
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ fn align_of_val_basic() {
|
||||
|
||||
#[test]
|
||||
fn test_swap() {
|
||||
let mut x = 31337i;
|
||||
let mut y = 42i;
|
||||
let mut x = 31337;
|
||||
let mut y = 42;
|
||||
swap(&mut x, &mut y);
|
||||
assert_eq!(x, 42);
|
||||
assert_eq!(y, 31337);
|
||||
@ -87,7 +87,7 @@ fn test_replace() {
|
||||
|
||||
#[test]
|
||||
fn test_transmute_copy() {
|
||||
assert_eq!(1u, unsafe { transmute_copy(&1i) });
|
||||
assert_eq!(1u, unsafe { transmute_copy(&1) });
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -95,7 +95,7 @@ fn test_transmute() {
|
||||
trait Foo {}
|
||||
impl Foo for int {}
|
||||
|
||||
let a = box 100i as Box<Foo>;
|
||||
let a = box 100 as Box<Foo>;
|
||||
unsafe {
|
||||
let x: ::core::raw::TraitObject = transmute(a);
|
||||
assert!(*(x.data as *const int) == 100);
|
||||
@ -146,7 +146,7 @@ fn trait_static_method_call(b: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn match_option_some(b: &mut Bencher) {
|
||||
let x = Some(10i);
|
||||
let x = Some(10);
|
||||
b.iter(|| {
|
||||
match x {
|
||||
Some(y) => y,
|
||||
@ -157,11 +157,11 @@ fn match_option_some(b: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn match_vec_pattern(b: &mut Bencher) {
|
||||
let x = [1i,2,3,4,5,6];
|
||||
let x = [1,2,3,4,5,6];
|
||||
b.iter(|| {
|
||||
match x {
|
||||
[1,2,3,..] => 10i,
|
||||
_ => 11i,
|
||||
[1,2,3,..] => 10,
|
||||
_ => 11,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use std::mem::size_of;
|
||||
#[test]
|
||||
fn test_create_nonzero_instance() {
|
||||
let _a = unsafe {
|
||||
NonZero::new(21i)
|
||||
NonZero::new(21)
|
||||
};
|
||||
}
|
||||
|
||||
@ -28,14 +28,14 @@ fn test_size_nonzero_in_option() {
|
||||
#[test]
|
||||
fn test_match_on_nonzero_option() {
|
||||
let a = Some(unsafe {
|
||||
NonZero::new(42i)
|
||||
NonZero::new(42)
|
||||
});
|
||||
match a {
|
||||
Some(val) => assert_eq!(*val, 42),
|
||||
None => panic!("unexpected None while matching on Some(NonZero(_))")
|
||||
}
|
||||
|
||||
match unsafe { Some(NonZero::new(43i)) } {
|
||||
match unsafe { Some(NonZero::new(43)) } {
|
||||
Some(val) => assert_eq!(*val, 43),
|
||||
None => panic!("unexpected None while matching on Some(NonZero(_))")
|
||||
}
|
||||
@ -52,9 +52,9 @@ fn test_match_option_empty_vec() {
|
||||
|
||||
#[test]
|
||||
fn test_match_option_vec() {
|
||||
let a = Some(vec![1i, 2, 3, 4]);
|
||||
let a = Some(vec![1, 2, 3, 4]);
|
||||
match a {
|
||||
Some(v) => assert_eq!(v, vec![1i, 2, 3, 4]),
|
||||
Some(v) => assert_eq!(v, vec![1, 2, 3, 4]),
|
||||
None => panic!("unexpected None while matching on Some(vec![1, 2, 3, 4])")
|
||||
}
|
||||
}
|
||||
@ -63,9 +63,9 @@ fn test_match_option_vec() {
|
||||
fn test_match_option_rc() {
|
||||
use std::rc::Rc;
|
||||
|
||||
let five = Rc::new(5i);
|
||||
let five = Rc::new(5);
|
||||
match Some(five) {
|
||||
Some(r) => assert_eq!(*r, 5i),
|
||||
Some(r) => assert_eq!(*r, 5),
|
||||
None => panic!("unexpected None while matching on Some(Rc::new(5))")
|
||||
}
|
||||
}
|
||||
@ -74,9 +74,9 @@ fn test_match_option_rc() {
|
||||
fn test_match_option_arc() {
|
||||
use std::sync::Arc;
|
||||
|
||||
let five = Arc::new(5i);
|
||||
let five = Arc::new(5);
|
||||
match Some(five) {
|
||||
Some(a) => assert_eq!(*a, 5i),
|
||||
Some(a) => assert_eq!(*a, 5),
|
||||
None => panic!("unexpected None while matching on Some(Arc::new(5))")
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_signed_checked_div() {
|
||||
assert!(10i.checked_div(2) == Some(5));
|
||||
assert!(5i.checked_div(0) == None);
|
||||
assert!(10.checked_div(2) == Some(5));
|
||||
assert!(5.checked_div(0) == None);
|
||||
assert!(int::MIN.checked_div(-1) == None);
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ pub fn test_num<T>(ten: T, two: T) where
|
||||
+ Rem<Output=T> + Debug
|
||||
+ Copy
|
||||
{
|
||||
assert_eq!(ten.add(two), cast(12i).unwrap());
|
||||
assert_eq!(ten.sub(two), cast(8i).unwrap());
|
||||
assert_eq!(ten.mul(two), cast(20i).unwrap());
|
||||
assert_eq!(ten.div(two), cast(5i).unwrap());
|
||||
assert_eq!(ten.rem(two), cast(0i).unwrap());
|
||||
assert_eq!(ten.add(two), cast(12).unwrap());
|
||||
assert_eq!(ten.sub(two), cast(8).unwrap());
|
||||
assert_eq!(ten.mul(two), cast(20).unwrap());
|
||||
assert_eq!(ten.div(two), cast(5).unwrap());
|
||||
assert_eq!(ten.rem(two), cast(0).unwrap());
|
||||
|
||||
assert_eq!(ten.add(two), ten + two);
|
||||
assert_eq!(ten.sub(two), ten - two);
|
||||
|
@ -16,7 +16,7 @@ use core::clone::Clone;
|
||||
#[test]
|
||||
fn test_get_ptr() {
|
||||
unsafe {
|
||||
let x = box 0i;
|
||||
let x = box 0;
|
||||
let addr_x: *const int = mem::transmute(&*x);
|
||||
let opt = Some(x);
|
||||
let y = opt.unwrap();
|
||||
@ -59,7 +59,7 @@ fn test_get_resource() {
|
||||
}
|
||||
}
|
||||
|
||||
let i = Rc::new(RefCell::new(0i));
|
||||
let i = Rc::new(RefCell::new(0));
|
||||
{
|
||||
let x = r(i.clone());
|
||||
let opt = Some(x);
|
||||
@ -71,7 +71,7 @@ fn test_get_resource() {
|
||||
#[test]
|
||||
fn test_option_dance() {
|
||||
let x = Some(());
|
||||
let mut y = Some(5i);
|
||||
let mut y = Some(5);
|
||||
let mut y2 = 0;
|
||||
for _x in x.iter() {
|
||||
y2 = y.take().unwrap();
|
||||
@ -89,12 +89,12 @@ fn test_option_too_much_dance() {
|
||||
|
||||
#[test]
|
||||
fn test_and() {
|
||||
let x: Option<int> = Some(1i);
|
||||
assert_eq!(x.and(Some(2i)), Some(2));
|
||||
let x: Option<int> = Some(1);
|
||||
assert_eq!(x.and(Some(2)), Some(2));
|
||||
assert_eq!(x.and(None::<int>), None);
|
||||
|
||||
let x: Option<int> = None;
|
||||
assert_eq!(x.and(Some(2i)), None);
|
||||
assert_eq!(x.and(Some(2)), None);
|
||||
assert_eq!(x.and(None::<int>), None);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ fn test_or_else() {
|
||||
|
||||
#[test]
|
||||
fn test_unwrap() {
|
||||
assert_eq!(Some(1i).unwrap(), 1);
|
||||
assert_eq!(Some(1).unwrap(), 1);
|
||||
let s = Some("hello".to_string()).unwrap();
|
||||
assert_eq!(s, "hello");
|
||||
}
|
||||
@ -172,7 +172,7 @@ fn test_unwrap_or_else() {
|
||||
|
||||
#[test]
|
||||
fn test_iter() {
|
||||
let val = 5i;
|
||||
let val = 5;
|
||||
|
||||
let x = Some(val);
|
||||
let mut it = x.iter();
|
||||
@ -185,8 +185,8 @@ fn test_iter() {
|
||||
|
||||
#[test]
|
||||
fn test_mut_iter() {
|
||||
let val = 5i;
|
||||
let new_val = 11i;
|
||||
let val = 5;
|
||||
let new_val = 11;
|
||||
|
||||
let mut x = Some(val);
|
||||
{
|
||||
@ -223,13 +223,13 @@ fn test_ord() {
|
||||
/* FIXME(#20575)
|
||||
#[test]
|
||||
fn test_collect() {
|
||||
let v: Option<Vec<int>> = (0i..0).map(|_| Some(0i)).collect();
|
||||
let v: Option<Vec<int>> = (0..0).map(|_| Some(0i)).collect();
|
||||
assert!(v == Some(vec![]));
|
||||
|
||||
let v: Option<Vec<int>> = (0i..3).map(|x| Some(x)).collect();
|
||||
let v: Option<Vec<int>> = (0..3).map(|x| Some(x)).collect();
|
||||
assert!(v == Some(vec![0, 1, 2]));
|
||||
|
||||
let v: Option<Vec<int>> = (0i..3).map(|x| {
|
||||
let v: Option<Vec<int>> = (0..3).map(|x| {
|
||||
if x > 1 { None } else { Some(x) }
|
||||
}).collect();
|
||||
assert!(v == None);
|
||||
|
@ -84,7 +84,7 @@ fn test_as_ref() {
|
||||
assert_eq!(q.as_ref().unwrap(), &2);
|
||||
|
||||
// Lifetime inference
|
||||
let u = 2i;
|
||||
let u = 2;
|
||||
{
|
||||
let p: *const int = &u as *const _;
|
||||
assert_eq!(p.as_ref().unwrap(), &2);
|
||||
@ -102,7 +102,7 @@ fn test_as_mut() {
|
||||
assert!(q.as_mut().unwrap() == &mut 2);
|
||||
|
||||
// Lifetime inference
|
||||
let mut u = 2i;
|
||||
let mut u = 2;
|
||||
{
|
||||
let p: *mut int = &mut u as *mut _;
|
||||
assert!(p.as_mut().unwrap() == &mut 2);
|
||||
@ -113,7 +113,7 @@ fn test_as_mut() {
|
||||
#[test]
|
||||
fn test_ptr_addition() {
|
||||
unsafe {
|
||||
let xs = repeat(5i).take(16).collect::<Vec<_>>();
|
||||
let xs = repeat(5).take(16).collect::<Vec<_>>();
|
||||
let mut ptr = xs.as_ptr();
|
||||
let end = ptr.offset(16);
|
||||
|
||||
@ -131,7 +131,7 @@ fn test_ptr_addition() {
|
||||
m_ptr = m_ptr.offset(1);
|
||||
}
|
||||
|
||||
assert!(xs_mut == repeat(10i).take(16).collect::<Vec<_>>());
|
||||
assert!(xs_mut == repeat(10).take(16).collect::<Vec<_>>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,11 @@ pub fn op2() -> Result<int, &'static str> { Err("sadface") }
|
||||
|
||||
#[test]
|
||||
pub fn test_and() {
|
||||
assert_eq!(op1().and(Ok(667i)).unwrap(), 667);
|
||||
assert_eq!(op1().and(Ok(667)).unwrap(), 667);
|
||||
assert_eq!(op1().and(Err::<i32, &'static str>("bad")).unwrap_err(),
|
||||
"bad");
|
||||
|
||||
assert_eq!(op2().and(Ok(667i)).unwrap_err(), "sadface");
|
||||
assert_eq!(op2().and(Ok(667)).unwrap_err(), "sadface");
|
||||
assert_eq!(op2().and(Err::<i32,&'static str>("bad")).unwrap_err(),
|
||||
"sadface");
|
||||
}
|
||||
@ -68,20 +68,20 @@ pub fn test_impl_map_err() {
|
||||
/* FIXME(#20575)
|
||||
#[test]
|
||||
fn test_collect() {
|
||||
let v: Result<Vec<int>, ()> = (0i..0).map(|_| Ok::<int, ()>(0)).collect();
|
||||
let v: Result<Vec<int>, ()> = (0..0).map(|_| Ok::<int, ()>(0)).collect();
|
||||
assert!(v == Ok(vec![]));
|
||||
|
||||
let v: Result<Vec<int>, ()> = (0i..3).map(|x| Ok::<int, ()>(x)).collect();
|
||||
let v: Result<Vec<int>, ()> = (0..3).map(|x| Ok::<int, ()>(x)).collect();
|
||||
assert!(v == Ok(vec![0, 1, 2]));
|
||||
|
||||
let v: Result<Vec<int>, int> = (0i..3).map(|x| {
|
||||
let v: Result<Vec<int>, int> = (0..3).map(|x| {
|
||||
if x > 1 { Err(x) } else { Ok(x) }
|
||||
}).collect();
|
||||
assert!(v == Err(2));
|
||||
|
||||
// test that it does not take more elements than it needs
|
||||
let mut functions: [Box<Fn() -> Result<(), int>>; 3] =
|
||||
[box || Ok(()), box || Err(1i), box || panic!()];
|
||||
[box || Ok(()), box || Err(1), box || panic!()];
|
||||
|
||||
let v: Result<Vec<()>, int> = functions.iter_mut().map(|f| (*f)()).collect();
|
||||
assert!(v == Err(1));
|
||||
@ -101,7 +101,7 @@ pub fn test_fmt_default() {
|
||||
|
||||
#[test]
|
||||
pub fn test_unwrap_or() {
|
||||
let ok: Result<int, &'static str> = Ok(100i);
|
||||
let ok: Result<int, &'static str> = Ok(100);
|
||||
let ok_err: Result<int, &'static str> = Err("Err");
|
||||
|
||||
assert_eq!(ok.unwrap_or(50), 100);
|
||||
@ -112,7 +112,7 @@ pub fn test_unwrap_or() {
|
||||
pub fn test_unwrap_or_else() {
|
||||
fn handler(msg: &'static str) -> int {
|
||||
if msg == "I got this." {
|
||||
50i
|
||||
50
|
||||
} else {
|
||||
panic!("BadBad")
|
||||
}
|
||||
@ -130,7 +130,7 @@ pub fn test_unwrap_or_else() {
|
||||
pub fn test_unwrap_or_else_panic() {
|
||||
fn handler(msg: &'static str) -> int {
|
||||
if msg == "I got this." {
|
||||
50i
|
||||
50
|
||||
} else {
|
||||
panic!("BadBad")
|
||||
}
|
||||
|
@ -12,25 +12,25 @@ use core::result::Result::{Ok, Err};
|
||||
|
||||
#[test]
|
||||
fn binary_search_not_found() {
|
||||
let b = [1i, 2, 4, 6, 8, 9];
|
||||
let b = [1, 2, 4, 6, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&6)) == Ok(3));
|
||||
let b = [1i, 2, 4, 6, 8, 9];
|
||||
let b = [1, 2, 4, 6, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&5)) == Err(3));
|
||||
let b = [1i, 2, 4, 6, 7, 8, 9];
|
||||
let b = [1, 2, 4, 6, 7, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&6)) == Ok(3));
|
||||
let b = [1i, 2, 4, 6, 7, 8, 9];
|
||||
let b = [1, 2, 4, 6, 7, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&5)) == Err(3));
|
||||
let b = [1i, 2, 4, 6, 8, 9];
|
||||
let b = [1, 2, 4, 6, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&8)) == Ok(4));
|
||||
let b = [1i, 2, 4, 6, 8, 9];
|
||||
let b = [1, 2, 4, 6, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&7)) == Err(4));
|
||||
let b = [1i, 2, 4, 6, 7, 8, 9];
|
||||
let b = [1, 2, 4, 6, 7, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&8)) == Ok(5));
|
||||
let b = [1i, 2, 4, 5, 6, 8, 9];
|
||||
let b = [1, 2, 4, 5, 6, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&7)) == Err(5));
|
||||
let b = [1i, 2, 4, 5, 6, 8, 9];
|
||||
let b = [1, 2, 4, 5, 6, 8, 9];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&0)) == Err(0));
|
||||
let b = [1i, 2, 4, 5, 6, 8];
|
||||
let b = [1, 2, 4, 5, 6, 8];
|
||||
assert!(b.binary_search_by(|v| v.cmp(&9)) == Err(6));
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ use std::cmp::Ordering::{Equal, Less, Greater};
|
||||
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let a = (1i, "2");
|
||||
let a = (1, "2");
|
||||
let b = a.clone();
|
||||
assert_eq!(a, b);
|
||||
}
|
||||
@ -59,10 +59,10 @@ fn test_tuple_cmp() {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let s = format!("{:?}", (1i,));
|
||||
let s = format!("{:?}", (1,));
|
||||
assert_eq!(s, "(1,)");
|
||||
let s = format!("{:?}", (1i, true));
|
||||
let s = format!("{:?}", (1, true));
|
||||
assert_eq!(s, "(1, true)");
|
||||
let s = format!("{:?}", (1i, "hi", true));
|
||||
let s = format!("{:?}", (1, "hi", true));
|
||||
assert_eq!(s, "(1, \"hi\", true)");
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
//! error!("this is printed by default");
|
||||
//!
|
||||
//! if log_enabled!(log::INFO) {
|
||||
//! let x = 3i * 4i; // expensive computation
|
||||
//! let x = 3 * 4; // expensive computation
|
||||
//! info!("the answer was: {:?}", x);
|
||||
//! }
|
||||
//! }
|
||||
|
@ -119,7 +119,7 @@ macro_rules! warn {
|
||||
/// #[macro_use] extern crate log;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let ret = 3i;
|
||||
/// let ret = 3;
|
||||
/// 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=10i, y=20i);
|
||||
/// debug!("x = {x}, y = {y}", x=10, y=20);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -311,36 +311,36 @@ mod tests {
|
||||
}}
|
||||
}
|
||||
|
||||
t!(vec!(Weighted { weight: 1, item: 10i}), [10]);
|
||||
t!(vec!(Weighted { weight: 1, item: 10}), [10]);
|
||||
|
||||
// skip some
|
||||
t!(vec!(Weighted { weight: 0, item: 20i},
|
||||
Weighted { weight: 2, item: 21i},
|
||||
Weighted { weight: 0, item: 22i},
|
||||
Weighted { weight: 1, item: 23i}),
|
||||
t!(vec!(Weighted { weight: 0, item: 20},
|
||||
Weighted { weight: 2, item: 21},
|
||||
Weighted { weight: 0, item: 22},
|
||||
Weighted { weight: 1, item: 23}),
|
||||
[21,21, 23]);
|
||||
|
||||
// different weights
|
||||
t!(vec!(Weighted { weight: 4, item: 30i},
|
||||
Weighted { weight: 3, item: 31i}),
|
||||
t!(vec!(Weighted { weight: 4, item: 30},
|
||||
Weighted { weight: 3, item: 31}),
|
||||
[30,30,30,30, 31,31,31]);
|
||||
|
||||
// check that we're binary searching
|
||||
// correctly with some vectors of odd
|
||||
// length.
|
||||
t!(vec!(Weighted { weight: 1, item: 40i},
|
||||
Weighted { weight: 1, item: 41i},
|
||||
Weighted { weight: 1, item: 42i},
|
||||
Weighted { weight: 1, item: 43i},
|
||||
Weighted { weight: 1, item: 44i}),
|
||||
t!(vec!(Weighted { weight: 1, item: 40},
|
||||
Weighted { weight: 1, item: 41},
|
||||
Weighted { weight: 1, item: 42},
|
||||
Weighted { weight: 1, item: 43},
|
||||
Weighted { weight: 1, item: 44}),
|
||||
[40, 41, 42, 43, 44]);
|
||||
t!(vec!(Weighted { weight: 1, item: 50i},
|
||||
Weighted { weight: 1, item: 51i},
|
||||
Weighted { weight: 1, item: 52i},
|
||||
Weighted { weight: 1, item: 53i},
|
||||
Weighted { weight: 1, item: 54i},
|
||||
Weighted { weight: 1, item: 55i},
|
||||
Weighted { weight: 1, item: 56i}),
|
||||
t!(vec!(Weighted { weight: 1, item: 50},
|
||||
Weighted { weight: 1, item: 51},
|
||||
Weighted { weight: 1, item: 52},
|
||||
Weighted { weight: 1, item: 53},
|
||||
Weighted { weight: 1, item: 54},
|
||||
Weighted { weight: 1, item: 55},
|
||||
Weighted { weight: 1, item: 56}),
|
||||
[50, 51, 52, 53, 54, 55, 56]);
|
||||
}
|
||||
|
||||
@ -350,15 +350,15 @@ mod tests {
|
||||
}
|
||||
#[test] #[should_fail]
|
||||
fn test_weighted_choice_zero_weight() {
|
||||
WeightedChoice::new(&mut [Weighted { weight: 0, item: 0i},
|
||||
Weighted { weight: 0, item: 1i}]);
|
||||
WeightedChoice::new(&mut [Weighted { weight: 0, item: 0},
|
||||
Weighted { weight: 0, item: 1}]);
|
||||
}
|
||||
#[test] #[should_fail]
|
||||
fn test_weighted_choice_weight_overflows() {
|
||||
let x = (-1) as uint / 2; // x + x + 2 is the overflow
|
||||
WeightedChoice::new(&mut [Weighted { weight: x, item: 0i },
|
||||
Weighted { weight: 1, item: 1i },
|
||||
Weighted { weight: x, item: 2i },
|
||||
Weighted { weight: 1, item: 3i }]);
|
||||
WeightedChoice::new(&mut [Weighted { weight: x, item: 0 },
|
||||
Weighted { weight: 1, item: 1 },
|
||||
Weighted { weight: x, item: 2 },
|
||||
Weighted { weight: 1, item: 3 }]);
|
||||
}
|
||||
}
|
||||
|
@ -171,12 +171,12 @@ mod tests {
|
||||
#[should_fail]
|
||||
#[test]
|
||||
fn test_range_bad_limits_equal() {
|
||||
Range::new(10i, 10i);
|
||||
Range::new(10, 10);
|
||||
}
|
||||
#[should_fail]
|
||||
#[test]
|
||||
fn test_range_bad_limits_flipped() {
|
||||
Range::new(10i, 5i);
|
||||
Range::new(10, 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -152,7 +152,7 @@ pub trait Rng : Sized {
|
||||
// (3) adds more `unsafe` that needs to be checked, (4)
|
||||
// probably doesn't give much performance gain if
|
||||
// optimisations are on.
|
||||
let mut count = 0i;
|
||||
let mut count = 0;
|
||||
let mut num = 0;
|
||||
for byte in dest.iter_mut() {
|
||||
if count == 0 {
|
||||
@ -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));
|
||||
/// assert_eq!(rng.choose(&choices[..0]), None);
|
||||
@ -290,7 +290,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);
|
||||
|
@ -493,7 +493,7 @@ pub struct BoxPointers;
|
||||
impl BoxPointers {
|
||||
fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
|
||||
span: Span, ty: Ty<'tcx>) {
|
||||
let mut n_uniq = 0i;
|
||||
let mut n_uniq = 0u;
|
||||
ty::fold_ty(cx.tcx, ty, |t| {
|
||||
match t.sty {
|
||||
ty::ty_uniq(_) => {
|
||||
|
@ -236,7 +236,7 @@ impl<'a> SpanUtils<'a> {
|
||||
|
||||
let mut toks = self.retokenise_span(span);
|
||||
// We keep track of how many brackets we're nested in
|
||||
let mut bracket_count = 0i;
|
||||
let mut bracket_count = 0;
|
||||
loop {
|
||||
let ts = toks.real_token();
|
||||
if ts.tok == token::Eof {
|
||||
|
@ -1078,7 +1078,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
let sw = if kind == Switch {
|
||||
build::Switch(bcx, test_val, else_cx.llbb, opts.len())
|
||||
} else {
|
||||
C_int(ccx, 0i) // Placeholder for when not using a switch
|
||||
C_int(ccx, 0) // Placeholder for when not using a switch
|
||||
};
|
||||
|
||||
let defaults = enter_default(else_cx, dm, m, col, val);
|
||||
|
@ -973,9 +973,9 @@ pub fn lltype_for_foreign_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
fn add_argument_attributes(tys: &ForeignTypes,
|
||||
llfn: ValueRef) {
|
||||
let mut i = if tys.fn_ty.ret_ty.is_indirect() {
|
||||
1i
|
||||
1
|
||||
} else {
|
||||
0i
|
||||
0
|
||||
};
|
||||
|
||||
match tys.fn_ty.ret_ty.attr {
|
||||
|
@ -499,7 +499,7 @@ pub fn iter_vec_raw<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||
CondBr(header_bcx, not_yet_at_end, body_bcx.llbb, next_bcx.llbb, DebugLoc::None);
|
||||
let body_bcx = f(body_bcx, data_ptr, vt.unit_ty);
|
||||
AddIncomingToPhi(data_ptr, InBoundsGEP(body_bcx, data_ptr,
|
||||
&[C_int(bcx.ccx(), 1i)]),
|
||||
&[C_int(bcx.ccx(), 1)]),
|
||||
body_bcx.llbb);
|
||||
Br(body_bcx, header_bcx.llbb, DebugLoc::None);
|
||||
next_bcx
|
||||
|
@ -116,7 +116,7 @@ impl FromHex for str {
|
||||
fn from_hex(&self) -> Result<Vec<u8>, FromHexError> {
|
||||
// This may be an overestimate if there is any whitespace
|
||||
let mut b = Vec::with_capacity(self.len() / 2);
|
||||
let mut modulus = 0i;
|
||||
let mut modulus = 0;
|
||||
let mut buf = 0u8;
|
||||
|
||||
for (idx, byte) in self.bytes().enumerate() {
|
||||
|
@ -3937,7 +3937,7 @@ mod tests {
|
||||
hash_map.insert("a".to_string(), 1u);
|
||||
hash_map.insert("b".to_string(), 2);
|
||||
assert_eq!(hash_map.to_json(), object);
|
||||
assert_eq!(Some(15i).to_json(), I64(15));
|
||||
assert_eq!(Some(15).to_json(), I64(15));
|
||||
assert_eq!(Some(15u).to_json(), U64(15));
|
||||
assert_eq!(None::<int>.to_json(), Null);
|
||||
}
|
||||
@ -3997,7 +3997,7 @@ mod tests {
|
||||
|
||||
fn big_json() -> string::String {
|
||||
let mut src = "[\n".to_string();
|
||||
for _ in 0i..500 {
|
||||
for _ in 0..500 {
|
||||
src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \
|
||||
[1,2,3]},"#);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ fn new_insert_drop(b : &mut Bencher) {
|
||||
|
||||
b.iter(|| {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(0i, 0i);
|
||||
m.insert(0, 0);
|
||||
assert_eq!(m.len(), 1);
|
||||
})
|
||||
}
|
||||
@ -43,7 +43,7 @@ fn grow_by_insertion(b: &mut Bencher) {
|
||||
|
||||
let mut m = HashMap::new();
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
m.insert(i, i);
|
||||
}
|
||||
|
||||
@ -61,12 +61,12 @@ fn find_existing(b: &mut Bencher) {
|
||||
|
||||
let mut m = HashMap::new();
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
m.insert(i, i);
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
m.contains_key(&i);
|
||||
}
|
||||
});
|
||||
@ -78,12 +78,12 @@ fn find_nonexisting(b: &mut Bencher) {
|
||||
|
||||
let mut m = HashMap::new();
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
m.insert(i, i);
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
for i in range_inclusive(1001i, 2000) {
|
||||
for i in range_inclusive(1001, 2000) {
|
||||
m.contains_key(&i);
|
||||
}
|
||||
});
|
||||
@ -95,11 +95,11 @@ fn hashmap_as_queue(b: &mut Bencher) {
|
||||
|
||||
let mut m = HashMap::new();
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
m.insert(i, i);
|
||||
}
|
||||
|
||||
let mut k = 1i;
|
||||
let mut k = 1;
|
||||
|
||||
b.iter(|| {
|
||||
m.remove(&k);
|
||||
@ -114,11 +114,11 @@ fn get_remove_insert(b: &mut Bencher) {
|
||||
|
||||
let mut m = HashMap::new();
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
m.insert(i, i);
|
||||
}
|
||||
|
||||
let mut k = 1i;
|
||||
let mut k = 1;
|
||||
|
||||
b.iter(|| {
|
||||
m.get(&(k + 400));
|
||||
|
@ -536,7 +536,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
///
|
||||
/// let s = RandomState::new();
|
||||
/// let mut map = HashMap::with_hash_state(s);
|
||||
/// map.insert(1i, 2u);
|
||||
/// map.insert(1, 2u);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
|
||||
@ -564,7 +564,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
///
|
||||
/// let s = RandomState::new();
|
||||
/// let mut map = HashMap::with_capacity_and_hash_state(10, s);
|
||||
/// map.insert(1i, 2u);
|
||||
/// map.insert(1, 2u);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
|
||||
@ -809,7 +809,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map = HashMap::new();
|
||||
/// map.insert("a", 1i);
|
||||
/// map.insert("a", 1);
|
||||
/// map.insert("b", 2);
|
||||
/// map.insert("c", 3);
|
||||
///
|
||||
@ -834,7 +834,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map = HashMap::new();
|
||||
/// map.insert("a", 1i);
|
||||
/// map.insert("a", 1);
|
||||
/// map.insert("b", 2);
|
||||
/// map.insert("c", 3);
|
||||
///
|
||||
@ -859,7 +859,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map = HashMap::new();
|
||||
/// map.insert("a", 1i);
|
||||
/// map.insert("a", 1);
|
||||
/// map.insert("b", 2);
|
||||
/// map.insert("c", 3);
|
||||
///
|
||||
@ -882,7 +882,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map = HashMap::new();
|
||||
/// map.insert("a", 1i);
|
||||
/// map.insert("a", 1);
|
||||
/// map.insert("b", 2);
|
||||
/// map.insert("c", 3);
|
||||
///
|
||||
@ -910,7 +910,7 @@ impl<K, V, S, H> HashMap<K, V, S>
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map = HashMap::new();
|
||||
/// map.insert("a", 1i);
|
||||
/// map.insert("a", 1);
|
||||
/// map.insert("b", 2);
|
||||
/// map.insert("c", 3);
|
||||
///
|
||||
@ -1622,7 +1622,7 @@ mod test_map {
|
||||
fn test_create_capacity_zero() {
|
||||
let mut m = HashMap::with_capacity(0);
|
||||
|
||||
assert!(m.insert(1i, 1i).is_none());
|
||||
assert!(m.insert(1, 1).is_none());
|
||||
|
||||
assert!(m.contains_key(&1));
|
||||
assert!(!m.contains_key(&0));
|
||||
@ -1632,9 +1632,9 @@ mod test_map {
|
||||
fn test_insert() {
|
||||
let mut m = HashMap::new();
|
||||
assert_eq!(m.len(), 0);
|
||||
assert!(m.insert(1i, 2i).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert_eq!(m.len(), 1);
|
||||
assert!(m.insert(2i, 4i).is_none());
|
||||
assert!(m.insert(2, 4).is_none());
|
||||
assert_eq!(m.len(), 2);
|
||||
assert_eq!(*m.get(&1).unwrap(), 2);
|
||||
assert_eq!(*m.get(&2).unwrap(), 4);
|
||||
@ -1674,7 +1674,7 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_drops() {
|
||||
DROP_VECTOR.with(|slot| {
|
||||
*slot.borrow_mut() = repeat(0i).take(200).collect();
|
||||
*slot.borrow_mut() = repeat(0).take(200).collect();
|
||||
});
|
||||
|
||||
{
|
||||
@ -1807,10 +1807,10 @@ mod test_map {
|
||||
|
||||
// Try this a few times to make sure we never screw up the hashmap's
|
||||
// internal state.
|
||||
for _ in 0i..10 {
|
||||
for _ in 0..10 {
|
||||
assert!(m.is_empty());
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
assert!(m.insert(i, i).is_none());
|
||||
|
||||
for j in range_inclusive(1, i) {
|
||||
@ -1824,12 +1824,12 @@ mod test_map {
|
||||
}
|
||||
}
|
||||
|
||||
for i in range_inclusive(1001i, 2000) {
|
||||
for i in range_inclusive(1001, 2000) {
|
||||
assert!(!m.contains_key(&i));
|
||||
}
|
||||
|
||||
// remove forwards
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
assert!(m.remove(&i).is_some());
|
||||
|
||||
for j in range_inclusive(1, i) {
|
||||
@ -1841,16 +1841,16 @@ mod test_map {
|
||||
}
|
||||
}
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
assert!(!m.contains_key(&i));
|
||||
}
|
||||
|
||||
for i in range_inclusive(1i, 1000) {
|
||||
for i in range_inclusive(1, 1000) {
|
||||
assert!(m.insert(i, i).is_none());
|
||||
}
|
||||
|
||||
// remove backwards
|
||||
for i in range_step_inclusive(1000i, 1, -1) {
|
||||
for i in range_step_inclusive(1000, 1, -1) {
|
||||
assert!(m.remove(&i).is_some());
|
||||
|
||||
for j in range_inclusive(i, 1000) {
|
||||
@ -1867,9 +1867,9 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_find_mut() {
|
||||
let mut m = HashMap::new();
|
||||
assert!(m.insert(1i, 12i).is_none());
|
||||
assert!(m.insert(2i, 8i).is_none());
|
||||
assert!(m.insert(5i, 14i).is_none());
|
||||
assert!(m.insert(1, 12).is_none());
|
||||
assert!(m.insert(2, 8).is_none());
|
||||
assert!(m.insert(5, 14).is_none());
|
||||
let new = 100;
|
||||
match m.get_mut(&5) {
|
||||
None => panic!(), Some(x) => *x = new
|
||||
@ -1880,18 +1880,18 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_insert_overwrite() {
|
||||
let mut m = HashMap::new();
|
||||
assert!(m.insert(1i, 2i).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert_eq!(*m.get(&1).unwrap(), 2);
|
||||
assert!(!m.insert(1i, 3i).is_none());
|
||||
assert!(!m.insert(1, 3).is_none());
|
||||
assert_eq!(*m.get(&1).unwrap(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_insert_conflicts() {
|
||||
let mut m = HashMap::with_capacity(4);
|
||||
assert!(m.insert(1i, 2i).is_none());
|
||||
assert!(m.insert(5i, 3i).is_none());
|
||||
assert!(m.insert(9i, 4i).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(m.insert(5, 3).is_none());
|
||||
assert!(m.insert(9, 4).is_none());
|
||||
assert_eq!(*m.get(&9).unwrap(), 4);
|
||||
assert_eq!(*m.get(&5).unwrap(), 3);
|
||||
assert_eq!(*m.get(&1).unwrap(), 2);
|
||||
@ -1900,7 +1900,7 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_conflict_remove() {
|
||||
let mut m = HashMap::with_capacity(4);
|
||||
assert!(m.insert(1i, 2i).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert_eq!(*m.get(&1).unwrap(), 2);
|
||||
assert!(m.insert(5, 3).is_none());
|
||||
assert_eq!(*m.get(&1).unwrap(), 2);
|
||||
@ -1917,7 +1917,7 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_is_empty() {
|
||||
let mut m = HashMap::with_capacity(4);
|
||||
assert!(m.insert(1i, 2i).is_none());
|
||||
assert!(m.insert(1, 2).is_none());
|
||||
assert!(!m.is_empty());
|
||||
assert!(m.remove(&1).is_some());
|
||||
assert!(m.is_empty());
|
||||
@ -1926,7 +1926,7 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_pop() {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(1i, 2i);
|
||||
m.insert(1, 2);
|
||||
assert_eq!(m.remove(&1), Some(2));
|
||||
assert_eq!(m.remove(&1), None);
|
||||
}
|
||||
@ -1950,7 +1950,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_keys() {
|
||||
let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')];
|
||||
let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')];
|
||||
let map = vec.into_iter().collect::<HashMap<int, char>>();
|
||||
let keys = map.keys().map(|&k| k).collect::<Vec<int>>();
|
||||
assert_eq!(keys.len(), 3);
|
||||
@ -1961,7 +1961,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_values() {
|
||||
let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')];
|
||||
let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')];
|
||||
let map = vec.into_iter().collect::<HashMap<int, char>>();
|
||||
let values = map.values().map(|&v| v).collect::<Vec<char>>();
|
||||
assert_eq!(values.len(), 3);
|
||||
@ -1973,8 +1973,8 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_find() {
|
||||
let mut m = HashMap::new();
|
||||
assert!(m.get(&1i).is_none());
|
||||
m.insert(1i, 2i);
|
||||
assert!(m.get(&1).is_none());
|
||||
m.insert(1, 2);
|
||||
match m.get(&1) {
|
||||
None => panic!(),
|
||||
Some(v) => assert_eq!(*v, 2)
|
||||
@ -1984,17 +1984,17 @@ mod test_map {
|
||||
#[test]
|
||||
fn test_eq() {
|
||||
let mut m1 = HashMap::new();
|
||||
m1.insert(1i, 2i);
|
||||
m1.insert(2i, 3i);
|
||||
m1.insert(3i, 4i);
|
||||
m1.insert(1, 2);
|
||||
m1.insert(2, 3);
|
||||
m1.insert(3, 4);
|
||||
|
||||
let mut m2 = HashMap::new();
|
||||
m2.insert(1i, 2i);
|
||||
m2.insert(2i, 3i);
|
||||
m2.insert(1, 2);
|
||||
m2.insert(2, 3);
|
||||
|
||||
assert!(m1 != m2);
|
||||
|
||||
m2.insert(3i, 4i);
|
||||
m2.insert(3, 4);
|
||||
|
||||
assert_eq!(m1, m2);
|
||||
}
|
||||
@ -2004,8 +2004,8 @@ mod test_map {
|
||||
let mut map: HashMap<int, int> = HashMap::new();
|
||||
let empty: HashMap<int, int> = HashMap::new();
|
||||
|
||||
map.insert(1i, 2i);
|
||||
map.insert(3i, 4i);
|
||||
map.insert(1, 2);
|
||||
map.insert(3, 4);
|
||||
|
||||
let map_str = format!("{:?}", map);
|
||||
|
||||
@ -2127,7 +2127,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_from_iter() {
|
||||
let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
|
||||
let map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
@ -2138,7 +2138,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_size_hint() {
|
||||
let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
|
||||
let map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
@ -2151,7 +2151,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_iter_len() {
|
||||
let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
|
||||
let map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
@ -2164,7 +2164,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_mut_size_hint() {
|
||||
let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
|
||||
let mut map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
@ -2177,7 +2177,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_iter_mut_len() {
|
||||
let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
|
||||
|
||||
let mut map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
@ -2213,7 +2213,7 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
fn test_entry(){
|
||||
let xs = [(1i, 10i), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
|
||||
let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
|
||||
|
||||
let mut map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
|
@ -168,7 +168,7 @@ impl<T, S, H> HashSet<T, S>
|
||||
///
|
||||
/// let s = RandomState::new();
|
||||
/// let mut set = HashSet::with_capacity_and_hash_state(10u, s);
|
||||
/// set.insert(1i);
|
||||
/// set.insert(1);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
|
||||
@ -290,8 +290,8 @@ impl<T, S, H> HashSet<T, S>
|
||||
///
|
||||
/// ```
|
||||
/// 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) {
|
||||
@ -299,12 +299,12 @@ impl<T, S, H> HashSet<T, S>
|
||||
/// }
|
||||
///
|
||||
/// 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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S> {
|
||||
@ -320,8 +320,8 @@ impl<T, S, H> HashSet<T, S>
|
||||
///
|
||||
/// ```
|
||||
/// 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) {
|
||||
@ -332,7 +332,7 @@ impl<T, S, H> HashSet<T, S>
|
||||
/// 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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, S>)
|
||||
@ -346,8 +346,8 @@ impl<T, S, H> HashSet<T, S>
|
||||
///
|
||||
/// ```
|
||||
/// 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) {
|
||||
@ -355,7 +355,7 @@ impl<T, S, H> HashSet<T, S>
|
||||
/// }
|
||||
///
|
||||
/// 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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> {
|
||||
@ -371,8 +371,8 @@ impl<T, S, H> HashSet<T, S>
|
||||
///
|
||||
/// ```
|
||||
/// 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) {
|
||||
@ -380,7 +380,7 @@ impl<T, S, H> HashSet<T, S>
|
||||
/// }
|
||||
///
|
||||
/// 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(feature = "rust1", since = "1.0.0")]
|
||||
pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
|
||||
@ -955,8 +955,8 @@ mod test_set {
|
||||
let mut ys = HashSet::new();
|
||||
assert!(xs.is_disjoint(&ys));
|
||||
assert!(ys.is_disjoint(&xs));
|
||||
assert!(xs.insert(5i));
|
||||
assert!(ys.insert(11i));
|
||||
assert!(xs.insert(5));
|
||||
assert!(ys.insert(11));
|
||||
assert!(xs.is_disjoint(&ys));
|
||||
assert!(ys.is_disjoint(&xs));
|
||||
assert!(xs.insert(7));
|
||||
@ -974,13 +974,13 @@ mod test_set {
|
||||
#[test]
|
||||
fn test_subset_and_superset() {
|
||||
let mut a = HashSet::new();
|
||||
assert!(a.insert(0i));
|
||||
assert!(a.insert(0));
|
||||
assert!(a.insert(5));
|
||||
assert!(a.insert(11));
|
||||
assert!(a.insert(7));
|
||||
|
||||
let mut b = HashSet::new();
|
||||
assert!(b.insert(0i));
|
||||
assert!(b.insert(0));
|
||||
assert!(b.insert(7));
|
||||
assert!(b.insert(19));
|
||||
assert!(b.insert(250));
|
||||
@ -1018,7 +1018,7 @@ mod test_set {
|
||||
let mut a = HashSet::new();
|
||||
let mut b = HashSet::new();
|
||||
|
||||
assert!(a.insert(11i));
|
||||
assert!(a.insert(11));
|
||||
assert!(a.insert(1));
|
||||
assert!(a.insert(3));
|
||||
assert!(a.insert(77));
|
||||
@ -1026,7 +1026,7 @@ mod test_set {
|
||||
assert!(a.insert(5));
|
||||
assert!(a.insert(-5));
|
||||
|
||||
assert!(b.insert(2i));
|
||||
assert!(b.insert(2));
|
||||
assert!(b.insert(11));
|
||||
assert!(b.insert(77));
|
||||
assert!(b.insert(-9));
|
||||
@ -1048,13 +1048,13 @@ mod test_set {
|
||||
let mut a = HashSet::new();
|
||||
let mut b = HashSet::new();
|
||||
|
||||
assert!(a.insert(1i));
|
||||
assert!(a.insert(1));
|
||||
assert!(a.insert(3));
|
||||
assert!(a.insert(5));
|
||||
assert!(a.insert(9));
|
||||
assert!(a.insert(11));
|
||||
|
||||
assert!(b.insert(3i));
|
||||
assert!(b.insert(3));
|
||||
assert!(b.insert(9));
|
||||
|
||||
let mut i = 0;
|
||||
@ -1071,13 +1071,13 @@ mod test_set {
|
||||
let mut a = HashSet::new();
|
||||
let mut b = HashSet::new();
|
||||
|
||||
assert!(a.insert(1i));
|
||||
assert!(a.insert(1));
|
||||
assert!(a.insert(3));
|
||||
assert!(a.insert(5));
|
||||
assert!(a.insert(9));
|
||||
assert!(a.insert(11));
|
||||
|
||||
assert!(b.insert(-2i));
|
||||
assert!(b.insert(-2));
|
||||
assert!(b.insert(3));
|
||||
assert!(b.insert(9));
|
||||
assert!(b.insert(14));
|
||||
@ -1097,7 +1097,7 @@ mod test_set {
|
||||
let mut a = HashSet::new();
|
||||
let mut b = HashSet::new();
|
||||
|
||||
assert!(a.insert(1i));
|
||||
assert!(a.insert(1));
|
||||
assert!(a.insert(3));
|
||||
assert!(a.insert(5));
|
||||
assert!(a.insert(9));
|
||||
@ -1106,7 +1106,7 @@ mod test_set {
|
||||
assert!(a.insert(19));
|
||||
assert!(a.insert(24));
|
||||
|
||||
assert!(b.insert(-2i));
|
||||
assert!(b.insert(-2));
|
||||
assert!(b.insert(1));
|
||||
assert!(b.insert(5));
|
||||
assert!(b.insert(9));
|
||||
@ -1124,7 +1124,7 @@ mod test_set {
|
||||
|
||||
#[test]
|
||||
fn test_from_iter() {
|
||||
let xs = [1i, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
let set: HashSet<int> = xs.iter().map(|&x| x).collect();
|
||||
|
||||
@ -1154,13 +1154,13 @@ mod test_set {
|
||||
// I'm keeping them around to prevent a regression.
|
||||
let mut s1 = HashSet::new();
|
||||
|
||||
s1.insert(1i);
|
||||
s1.insert(1);
|
||||
s1.insert(2);
|
||||
s1.insert(3);
|
||||
|
||||
let mut s2 = HashSet::new();
|
||||
|
||||
s2.insert(1i);
|
||||
s2.insert(1);
|
||||
s2.insert(2);
|
||||
|
||||
assert!(s1 != s2);
|
||||
@ -1175,7 +1175,7 @@ mod test_set {
|
||||
let mut set: HashSet<int> = HashSet::new();
|
||||
let empty: HashSet<int> = HashSet::new();
|
||||
|
||||
set.insert(1i);
|
||||
set.insert(1);
|
||||
set.insert(2);
|
||||
|
||||
let set_str = format!("{:?}", set);
|
||||
@ -1201,7 +1201,7 @@ mod test_set {
|
||||
let mut s: HashSet<int> = (1is..100).collect();
|
||||
|
||||
// try this a bunch of times to make sure we don't screw up internal state.
|
||||
for _ in 0i..20 {
|
||||
for _ in 0..20 {
|
||||
assert_eq!(s.len(), 99);
|
||||
|
||||
{
|
||||
|
@ -274,7 +274,7 @@ impl<K, V, M: Deref<Target=RawTable<K, V>>> Bucket<K, V, M> {
|
||||
// ... and it's zero at all other times.
|
||||
let maybe_wraparound_dist = (self.idx ^ (self.idx + 1)) & self.table.capacity();
|
||||
// Finally, we obtain the offset 1 or the offset -cap + 1.
|
||||
let dist = 1i - (maybe_wraparound_dist as int);
|
||||
let dist = 1 - (maybe_wraparound_dist as int);
|
||||
|
||||
self.idx += 1;
|
||||
|
||||
|
@ -29,10 +29,10 @@
|
||||
//! ```
|
||||
//! format!("Hello"); // => "Hello"
|
||||
//! format!("Hello, {}!", "world"); // => "Hello, world!"
|
||||
//! format!("The number is {}", 1i); // => "The number is 1"
|
||||
//! format!("{:?}", (3i, 4i)); // => "(3i, 4i)"
|
||||
//! format!("{value}", value=4i); // => "4"
|
||||
//! format!("{} {}", 1i, 2u); // => "1 2"
|
||||
//! format!("The number is {}", 1); // => "The number is 1"
|
||||
//! format!("{:?}", (3, 4)); // => "(3, 4)"
|
||||
//! format!("{value}", value=4); // => "4"
|
||||
//! format!("{} {}", 1, 2u); // => "1 2"
|
||||
//! ```
|
||||
//!
|
||||
//! From these, you can see that the first argument is a format string. It is
|
||||
@ -55,7 +55,7 @@
|
||||
//! the iterator advances. This leads to behavior like this:
|
||||
//!
|
||||
//! ```rust
|
||||
//! format!("{1} {} {0} {}", 1i, 2i); // => "2 1 1 2"
|
||||
//! format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
|
||||
//! ```
|
||||
//!
|
||||
//! The internal iterator over the argument has not been advanced by the time
|
||||
@ -83,8 +83,8 @@
|
||||
//!
|
||||
//! ```
|
||||
//! format!("{argument}", argument = "test"); // => "test"
|
||||
//! format!("{name} {}", 1i, name = 2i); // => "2 1"
|
||||
//! format!("{a} {c} {b}", a="a", b='b', c=3i); // => "a 3 b"
|
||||
//! format!("{name} {}", 1, name = 2); // => "2 1"
|
||||
//! format!("{a} {c} {b}", a="a", b='b', c=3); // => "a 3 b"
|
||||
//! ```
|
||||
//!
|
||||
//! It is illegal to put positional parameters (those without names) after
|
||||
@ -206,7 +206,7 @@
|
||||
//! let myvector = Vector2D { x: 3, y: 4 };
|
||||
//!
|
||||
//! println!("{}", myvector); // => "(3, 4)"
|
||||
//! println!("{:?}", myvector); // => "Vector2D {x: 3i, y:4i}"
|
||||
//! println!("{:?}", myvector); // => "Vector2D {x: 3, y:4}"
|
||||
//! println!("{:10.3b}", myvector); // => " 5.000"
|
||||
//! }
|
||||
//! ```
|
||||
|
@ -32,7 +32,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]
|
||||
@ -68,7 +68,7 @@ macro_rules! panic {
|
||||
/// ```
|
||||
/// format!("test");
|
||||
/// format!("hello {}", "world!");
|
||||
/// format!("x = {}, y = {y}", 10i, y = 30i);
|
||||
/// format!("x = {}, y = {y}", 10, y = 30);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -282,7 +282,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]
|
||||
|
@ -356,11 +356,11 @@ pub fn test_num<T>(ten: T, two: T) where
|
||||
+ Rem<Output=T> + Debug
|
||||
+ Copy
|
||||
{
|
||||
assert_eq!(ten.add(two), cast(12i).unwrap());
|
||||
assert_eq!(ten.sub(two), cast(8i).unwrap());
|
||||
assert_eq!(ten.mul(two), cast(20i).unwrap());
|
||||
assert_eq!(ten.div(two), cast(5i).unwrap());
|
||||
assert_eq!(ten.rem(two), cast(0i).unwrap());
|
||||
assert_eq!(ten.add(two), cast(12).unwrap());
|
||||
assert_eq!(ten.sub(two), cast(8).unwrap());
|
||||
assert_eq!(ten.mul(two), cast(20).unwrap());
|
||||
assert_eq!(ten.div(two), cast(5).unwrap());
|
||||
assert_eq!(ten.rem(two), cast(0).unwrap());
|
||||
|
||||
assert_eq!(ten.add(two), ten + two);
|
||||
assert_eq!(ten.sub(two), ten - two);
|
||||
@ -393,7 +393,7 @@ mod tests {
|
||||
assert_eq!(20u16, _20.to_u16().unwrap());
|
||||
assert_eq!(20u32, _20.to_u32().unwrap());
|
||||
assert_eq!(20u64, _20.to_u64().unwrap());
|
||||
assert_eq!(20i, _20.to_int().unwrap());
|
||||
assert_eq!(20, _20.to_int().unwrap());
|
||||
assert_eq!(20i8, _20.to_i8().unwrap());
|
||||
assert_eq!(20i16, _20.to_i16().unwrap());
|
||||
assert_eq!(20i32, _20.to_i32().unwrap());
|
||||
@ -406,7 +406,7 @@ mod tests {
|
||||
assert_eq!(_20, NumCast::from(20u16).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20u32).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20u64).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20i).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20i8).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20i16).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20i32).unwrap());
|
||||
@ -419,7 +419,7 @@ mod tests {
|
||||
assert_eq!(_20, cast(20u16).unwrap());
|
||||
assert_eq!(_20, cast(20u32).unwrap());
|
||||
assert_eq!(_20, cast(20u64).unwrap());
|
||||
assert_eq!(_20, cast(20i).unwrap());
|
||||
assert_eq!(_20, cast(20).unwrap());
|
||||
assert_eq!(_20, cast(20i8).unwrap());
|
||||
assert_eq!(_20, cast(20i16).unwrap());
|
||||
assert_eq!(_20, cast(20i32).unwrap());
|
||||
@ -438,7 +438,7 @@ mod tests {
|
||||
#[test] fn test_i16_cast() { test_cast_20!(20i16) }
|
||||
#[test] fn test_i32_cast() { test_cast_20!(20i32) }
|
||||
#[test] fn test_i64_cast() { test_cast_20!(20i64) }
|
||||
#[test] fn test_int_cast() { test_cast_20!(20i) }
|
||||
#[test] fn test_int_cast() { test_cast_20!(20) }
|
||||
#[test] fn test_f32_cast() { test_cast_20!(20f32) }
|
||||
#[test] fn test_f64_cast() { test_cast_20!(20f64) }
|
||||
|
||||
@ -831,23 +831,23 @@ mod tests {
|
||||
#[test]
|
||||
fn test_saturating_add_int() {
|
||||
use int::{MIN,MAX};
|
||||
assert_eq!(3i.saturating_add(5i), 8i);
|
||||
assert_eq!(3i.saturating_add(MAX-1), MAX);
|
||||
assert_eq!(3.saturating_add(5), 8);
|
||||
assert_eq!(3.saturating_add(MAX-1), MAX);
|
||||
assert_eq!(MAX.saturating_add(MAX), MAX);
|
||||
assert_eq!((MAX-2).saturating_add(1), MAX-1);
|
||||
assert_eq!(3i.saturating_add(-5i), -2i);
|
||||
assert_eq!(MIN.saturating_add(-1i), MIN);
|
||||
assert_eq!((-2i).saturating_add(-MAX), MIN);
|
||||
assert_eq!(3.saturating_add(-5), -2);
|
||||
assert_eq!(MIN.saturating_add(-1), MIN);
|
||||
assert_eq!((-2).saturating_add(-MAX), MIN);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_saturating_sub_int() {
|
||||
use int::{MIN,MAX};
|
||||
assert_eq!(3i.saturating_sub(5i), -2i);
|
||||
assert_eq!(MIN.saturating_sub(1i), MIN);
|
||||
assert_eq!((-2i).saturating_sub(MAX), MIN);
|
||||
assert_eq!(3i.saturating_sub(-5i), 8i);
|
||||
assert_eq!(3i.saturating_sub(-(MAX-1)), MAX);
|
||||
assert_eq!(3.saturating_sub(5), -2);
|
||||
assert_eq!(MIN.saturating_sub(1), MIN);
|
||||
assert_eq!((-2).saturating_sub(MAX), MIN);
|
||||
assert_eq!(3.saturating_sub(-5), 8);
|
||||
assert_eq!(3.saturating_sub(-(MAX-1)), MAX);
|
||||
assert_eq!(MAX.saturating_sub(-MAX), MAX);
|
||||
assert_eq!((MAX-2).saturating_sub(-1), MAX-1);
|
||||
}
|
||||
@ -1010,10 +1010,10 @@ mod tests {
|
||||
assert_eq!(result, naive_pow($num, $exp));
|
||||
}}
|
||||
}
|
||||
assert_pow!((3i, 0 ) => 1);
|
||||
assert_pow!((5i, 1 ) => 5);
|
||||
assert_pow!((-4i, 2 ) => 16);
|
||||
assert_pow!((8i, 3 ) => 512);
|
||||
assert_pow!((3, 0 ) => 1);
|
||||
assert_pow!((5, 1 ) => 5);
|
||||
assert_pow!((-4, 2 ) => 16);
|
||||
assert_pow!((8, 3 ) => 512);
|
||||
assert_pow!((2u64, 50) => 1125899906842624);
|
||||
}
|
||||
}
|
||||
|
@ -981,7 +981,7 @@ mod test {
|
||||
let initial_msg = "food-is-yummy";
|
||||
let overwrite_msg = "-the-bar!!";
|
||||
let final_msg = "foo-the-bar!!";
|
||||
let seek_idx = 3i;
|
||||
let seek_idx = 3;
|
||||
let mut read_mem = [0; 13];
|
||||
let tmpdir = tmpdir();
|
||||
let filename = &tmpdir.join("file_rt_io_file_test_seek_and_write.txt");
|
||||
@ -1101,7 +1101,7 @@ mod test {
|
||||
let dir = &tmpdir.join("di_readdir");
|
||||
check!(mkdir(dir, old_io::USER_RWX));
|
||||
let prefix = "foo";
|
||||
for n in 0i..3 {
|
||||
for n in 0..3 {
|
||||
let f = dir.join(format!("{}.txt", n));
|
||||
let mut w = check!(File::create(&f));
|
||||
let msg_str = format!("{}{}", prefix, n.to_string());
|
||||
|
@ -1160,7 +1160,7 @@ mod test {
|
||||
tx.send(TcpStream::connect(addr).unwrap()).unwrap();
|
||||
});
|
||||
let _l = rx.recv().unwrap();
|
||||
for i in 0i..1001 {
|
||||
for i in 0..1001 {
|
||||
match a.accept() {
|
||||
Ok(..) => break,
|
||||
Err(ref e) if e.kind == TimedOut => {}
|
||||
@ -1260,7 +1260,7 @@ mod test {
|
||||
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
|
||||
|
||||
s.set_timeout(Some(20));
|
||||
for i in 0i..1001 {
|
||||
for i in 0..1001 {
|
||||
match s.write(&[0; 128 * 1024]) {
|
||||
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
|
||||
Err(IoError { kind: TimedOut, .. }) => break,
|
||||
@ -1299,7 +1299,7 @@ mod test {
|
||||
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
|
||||
|
||||
tx.send(()).unwrap();
|
||||
for _ in 0i..100 {
|
||||
for _ in 0..100 {
|
||||
assert!(s.write(&[0;128 * 1024]).is_ok());
|
||||
}
|
||||
}
|
||||
@ -1318,7 +1318,7 @@ mod test {
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_write_timeout(Some(20));
|
||||
for i in 0i..1001 {
|
||||
for i in 0..1001 {
|
||||
match s.write(&[0; 128 * 1024]) {
|
||||
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
|
||||
Err(IoError { kind: TimedOut, .. }) => break,
|
||||
@ -1388,7 +1388,7 @@ mod test {
|
||||
});
|
||||
|
||||
// Try to ensure that the reading clone is indeed reading
|
||||
for _ in 0i..50 {
|
||||
for _ in 0..50 {
|
||||
::thread::Thread::yield_now();
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1142,7 @@ mod tests {
|
||||
fn test_zero() {
|
||||
let mut p = sleeper();
|
||||
p.signal_kill().unwrap();
|
||||
for _ in 0i..20 {
|
||||
for _ in 0..20 {
|
||||
if p.signal(0).is_err() {
|
||||
assert!(!p.wait().unwrap().success());
|
||||
return
|
||||
|
@ -1484,7 +1484,7 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_getenv_big() {
|
||||
let mut s = "".to_string();
|
||||
let mut i = 0i;
|
||||
let mut i = 0;
|
||||
while i < 100 {
|
||||
s.push_str("aaaaaaaaaa");
|
||||
i += 1;
|
||||
|
@ -427,7 +427,7 @@ pub fn random<T: Rand>() -> T {
|
||||
/// use std::rand::{thread_rng, sample};
|
||||
///
|
||||
/// let mut rng = thread_rng();
|
||||
/// let sample = sample(&mut rng, 1i..100, 5);
|
||||
/// let sample = sample(&mut rng, 1..100, 5);
|
||||
/// println!("{:?}", sample);
|
||||
/// ```
|
||||
pub fn sample<T, I: Iterator<Item=T>, R: Rng>(rng: &mut R,
|
||||
@ -481,16 +481,16 @@ mod test {
|
||||
fn test_gen_range() {
|
||||
let mut r = thread_rng();
|
||||
for _ in 0u..1000 {
|
||||
let a = r.gen_range(-3i, 42);
|
||||
let a = r.gen_range(-3, 42);
|
||||
assert!(a >= -3 && a < 42);
|
||||
assert_eq!(r.gen_range(0i, 1), 0);
|
||||
assert_eq!(r.gen_range(-12i, -11), -12);
|
||||
assert_eq!(r.gen_range(0, 1), 0);
|
||||
assert_eq!(r.gen_range(-12, -11), -12);
|
||||
}
|
||||
|
||||
for _ in 0u..1000 {
|
||||
let a = r.gen_range(10i, 42);
|
||||
let a = r.gen_range(10, 42);
|
||||
assert!(a >= 10 && a < 42);
|
||||
assert_eq!(r.gen_range(0i, 1), 0);
|
||||
assert_eq!(r.gen_range(0, 1), 0);
|
||||
assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000);
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ mod test {
|
||||
#[should_fail]
|
||||
fn test_gen_range_panic_int() {
|
||||
let mut r = thread_rng();
|
||||
r.gen_range(5i, -2);
|
||||
r.gen_range(5, -2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -544,7 +544,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_choose() {
|
||||
let mut r = thread_rng();
|
||||
assert_eq!(r.choose(&[1i, 1, 1]).map(|&x|x), Some(1));
|
||||
assert_eq!(r.choose(&[1, 1, 1]).map(|&x|x), Some(1));
|
||||
|
||||
let v: &[int] = &[];
|
||||
assert_eq!(r.choose(v), None);
|
||||
@ -555,16 +555,16 @@ mod test {
|
||||
let mut r = thread_rng();
|
||||
let empty: &mut [int] = &mut [];
|
||||
r.shuffle(empty);
|
||||
let mut one = [1i];
|
||||
let mut one = [1];
|
||||
r.shuffle(&mut one);
|
||||
let b: &[_] = &[1];
|
||||
assert_eq!(one, b);
|
||||
|
||||
let mut two = [1i, 2];
|
||||
let mut two = [1, 2];
|
||||
r.shuffle(&mut two);
|
||||
assert!(two == [1, 2] || two == [2, 1]);
|
||||
|
||||
let mut x = [1i, 1, 1];
|
||||
let mut x = [1, 1, 1];
|
||||
r.shuffle(&mut x);
|
||||
let b: &[_] = &[1, 1, 1];
|
||||
assert_eq!(x, b);
|
||||
@ -574,7 +574,7 @@ mod test {
|
||||
fn test_thread_rng() {
|
||||
let mut r = thread_rng();
|
||||
r.gen::<int>();
|
||||
let mut v = [1i, 1, 1];
|
||||
let mut v = [1, 1, 1];
|
||||
r.shuffle(&mut v);
|
||||
let b: &[_] = &[1, 1, 1];
|
||||
assert_eq!(v, b);
|
||||
@ -597,8 +597,8 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_sample() {
|
||||
let min_val = 1i;
|
||||
let max_val = 100i;
|
||||
let min_val = 1;
|
||||
let max_val = 100;
|
||||
|
||||
let mut r = thread_rng();
|
||||
let vals = (min_val..max_val).collect::<Vec<int>>();
|
||||
|
@ -193,7 +193,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_get_ref_method() {
|
||||
let mut f = Future::from_value(22i);
|
||||
let mut f = Future::from_value(22);
|
||||
assert_eq!(*f.get_ref(), 22);
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,9 @@
|
||||
//! // Create a simple streaming channel
|
||||
//! let (tx, rx) = channel();
|
||||
//! Thread::spawn(move|| {
|
||||
//! tx.send(10i).unwrap();
|
||||
//! tx.send(10).unwrap();
|
||||
//! });
|
||||
//! assert_eq!(rx.recv().unwrap(), 10i);
|
||||
//! assert_eq!(rx.recv().unwrap(), 10);
|
||||
//! ```
|
||||
//!
|
||||
//! Shared usage:
|
||||
@ -74,14 +74,14 @@
|
||||
//! // where tx is the sending half (tx for transmission), and rx is the receiving
|
||||
//! // half (rx for receiving).
|
||||
//! let (tx, rx) = channel();
|
||||
//! for i in 0i..10i {
|
||||
//! for i in 0..10 {
|
||||
//! let tx = tx.clone();
|
||||
//! Thread::spawn(move|| {
|
||||
//! tx.send(i).unwrap();
|
||||
//! });
|
||||
//! }
|
||||
//!
|
||||
//! for _ in 0i..10i {
|
||||
//! for _ in 0..10 {
|
||||
//! let j = rx.recv().unwrap();
|
||||
//! assert!(0 <= j && j < 10);
|
||||
//! }
|
||||
@ -514,15 +514,15 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
|
||||
/// let (tx, rx) = sync_channel(1);
|
||||
///
|
||||
/// // this returns immediately
|
||||
/// tx.send(1i).unwrap();
|
||||
/// tx.send(1).unwrap();
|
||||
///
|
||||
/// Thread::spawn(move|| {
|
||||
/// // this will block until the previous message has been received
|
||||
/// tx.send(2i).unwrap();
|
||||
/// tx.send(2).unwrap();
|
||||
/// });
|
||||
///
|
||||
/// assert_eq!(rx.recv().unwrap(), 1i);
|
||||
/// assert_eq!(rx.recv().unwrap(), 2i);
|
||||
/// assert_eq!(rx.recv().unwrap(), 1);
|
||||
/// assert_eq!(rx.recv().unwrap(), 2);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn sync_channel<T: Send>(bound: uint) -> (SyncSender<T>, Receiver<T>) {
|
||||
@ -562,11 +562,11 @@ impl<T: Send> Sender<T> {
|
||||
/// let (tx, rx) = channel();
|
||||
///
|
||||
/// // This send is always successful
|
||||
/// tx.send(1i).unwrap();
|
||||
/// tx.send(1).unwrap();
|
||||
///
|
||||
/// // This send will fail because the receiver is gone
|
||||
/// drop(rx);
|
||||
/// assert_eq!(tx.send(1i).err().unwrap().0, 1);
|
||||
/// assert_eq!(tx.send(1).err().unwrap().0, 1);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn send(&self, t: T) -> Result<(), SendError<T>> {
|
||||
@ -1045,7 +1045,7 @@ mod test {
|
||||
#[test]
|
||||
fn drop_full() {
|
||||
let (tx, _rx) = channel();
|
||||
tx.send(box 1i).unwrap();
|
||||
tx.send(box 1).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1053,7 +1053,7 @@ mod test {
|
||||
let (tx, _rx) = channel();
|
||||
drop(tx.clone());
|
||||
drop(tx.clone());
|
||||
tx.send(box 1i).unwrap();
|
||||
tx.send(box 1).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1147,7 +1147,7 @@ mod test {
|
||||
fn stress() {
|
||||
let (tx, rx) = channel::<int>();
|
||||
let t = Thread::scoped(move|| {
|
||||
for _ in 0u..10000 { tx.send(1i).unwrap(); }
|
||||
for _ in 0u..10000 { tx.send(1).unwrap(); }
|
||||
});
|
||||
for _ in 0u..10000 {
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
@ -1187,13 +1187,13 @@ mod test {
|
||||
let (tx2, rx2) = channel::<int>();
|
||||
let t1 = Thread::scoped(move|| {
|
||||
tx1.send(()).unwrap();
|
||||
for _ in 0i..40 {
|
||||
for _ in 0..40 {
|
||||
assert_eq!(rx2.recv().unwrap(), 1);
|
||||
}
|
||||
});
|
||||
rx1.recv().unwrap();
|
||||
let t2 = Thread::scoped(move|| {
|
||||
for _ in 0i..40 {
|
||||
for _ in 0..40 {
|
||||
tx2.send(1).unwrap();
|
||||
}
|
||||
});
|
||||
@ -1205,7 +1205,7 @@ mod test {
|
||||
fn recv_from_outside_runtime() {
|
||||
let (tx, rx) = channel::<int>();
|
||||
let t = Thread::scoped(move|| {
|
||||
for _ in 0i..40 {
|
||||
for _ in 0..40 {
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
}
|
||||
});
|
||||
@ -1391,9 +1391,9 @@ mod test {
|
||||
for _ in 0..stress_factor() {
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| {
|
||||
tx.send(box 10i).unwrap();
|
||||
tx.send(box 10).unwrap();
|
||||
});
|
||||
assert!(rx.recv().unwrap() == box 10i);
|
||||
assert!(rx.recv().unwrap() == box 10);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1429,8 +1429,8 @@ mod test {
|
||||
fn recv_a_lot() {
|
||||
// Regression test that we don't run out of stack in scheduler context
|
||||
let (tx, rx) = channel();
|
||||
for _ in 0i..10000 { tx.send(()).unwrap(); }
|
||||
for _ in 0i..10000 { rx.recv().unwrap(); }
|
||||
for _ in 0..10000 { tx.send(()).unwrap(); }
|
||||
for _ in 0..10000 { rx.recv().unwrap(); }
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1567,7 +1567,7 @@ mod sync_tests {
|
||||
#[test]
|
||||
fn drop_full() {
|
||||
let (tx, _rx) = sync_channel(1);
|
||||
tx.send(box 1i).unwrap();
|
||||
tx.send(box 1).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1855,9 +1855,9 @@ mod sync_tests {
|
||||
for _ in 0..stress_factor() {
|
||||
let (tx, rx) = sync_channel::<Box<int>>(0);
|
||||
let _t = Thread::spawn(move|| {
|
||||
tx.send(box 10i).unwrap();
|
||||
tx.send(box 10).unwrap();
|
||||
});
|
||||
assert!(rx.recv().unwrap() == box 10i);
|
||||
assert!(rx.recv().unwrap() == box 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_full() {
|
||||
let q = Queue::new();
|
||||
q.push(box 1i);
|
||||
q.push(box 2i);
|
||||
q.push(box 1);
|
||||
q.push(box 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -32,15 +32,15 @@
|
||||
//! let (tx1, rx1) = channel();
|
||||
//! let (tx2, rx2) = channel();
|
||||
//!
|
||||
//! tx1.send(1i).unwrap();
|
||||
//! tx2.send(2i).unwrap();
|
||||
//! tx1.send(1).unwrap();
|
||||
//! tx2.send(2).unwrap();
|
||||
//!
|
||||
//! select! {
|
||||
//! val = rx1.recv() => {
|
||||
//! assert_eq!(val.unwrap(), 1i);
|
||||
//! assert_eq!(val.unwrap(), 1);
|
||||
//! },
|
||||
//! val = rx2.recv() => {
|
||||
//! assert_eq!(val.unwrap(), 2i);
|
||||
//! assert_eq!(val.unwrap(), 2);
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
|
@ -253,9 +253,9 @@ mod test {
|
||||
fn smoke() {
|
||||
unsafe {
|
||||
let queue = Queue::new(0);
|
||||
queue.push(1i);
|
||||
queue.push(1);
|
||||
queue.push(2);
|
||||
assert_eq!(queue.pop(), Some(1i));
|
||||
assert_eq!(queue.pop(), Some(1));
|
||||
assert_eq!(queue.pop(), Some(2));
|
||||
assert_eq!(queue.pop(), None);
|
||||
queue.push(3);
|
||||
@ -270,7 +270,7 @@ mod test {
|
||||
fn peek() {
|
||||
unsafe {
|
||||
let queue = Queue::new(0);
|
||||
queue.push(vec![1i]);
|
||||
queue.push(vec![1]);
|
||||
|
||||
// Ensure the borrowchecker works
|
||||
match queue.peek() {
|
||||
@ -290,8 +290,8 @@ mod test {
|
||||
fn drop_full() {
|
||||
unsafe {
|
||||
let q = Queue::new(0);
|
||||
q.push(box 1i);
|
||||
q.push(box 2i);
|
||||
q.push(box 1);
|
||||
q.push(box 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ mod test {
|
||||
fn smoke_bound() {
|
||||
unsafe {
|
||||
let q = Queue::new(0);
|
||||
q.push(1i);
|
||||
q.push(1);
|
||||
q.push(2);
|
||||
assert_eq!(q.pop(), Some(1));
|
||||
assert_eq!(q.pop(), Some(2));
|
||||
@ -328,7 +328,7 @@ mod test {
|
||||
for _ in 0u..100000 {
|
||||
loop {
|
||||
match q2.pop() {
|
||||
Some(1i) => break,
|
||||
Some(1) => break,
|
||||
Some(_) => panic!(),
|
||||
None => {}
|
||||
}
|
||||
@ -336,7 +336,7 @@ mod test {
|
||||
}
|
||||
tx.send(()).unwrap();
|
||||
});
|
||||
for _ in 0i..100000 {
|
||||
for _ in 0..100000 {
|
||||
q.push(1);
|
||||
}
|
||||
rx.recv().unwrap();
|
||||
|
@ -428,7 +428,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_arc_condvar_poison() {
|
||||
let packet = Packet(Arc::new((Mutex::new(1i), Condvar::new())));
|
||||
let packet = Packet(Arc::new((Mutex::new(1), Condvar::new())));
|
||||
let packet2 = Packet(packet.0.clone());
|
||||
let (tx, rx) = channel();
|
||||
|
||||
@ -457,7 +457,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_mutex_arc_poison() {
|
||||
let arc = Arc::new(Mutex::new(1i));
|
||||
let arc = Arc::new(Mutex::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _ = Thread::scoped(move|| {
|
||||
let lock = arc2.lock().unwrap();
|
||||
@ -470,7 +470,7 @@ mod test {
|
||||
fn test_mutex_arc_nested() {
|
||||
// Tests nested mutexes and access
|
||||
// to underlying data.
|
||||
let arc = Arc::new(Mutex::new(1i));
|
||||
let arc = Arc::new(Mutex::new(1));
|
||||
let arc2 = Arc::new(Mutex::new(arc));
|
||||
let (tx, rx) = channel();
|
||||
let _t = Thread::spawn(move|| {
|
||||
@ -484,7 +484,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_mutex_arc_access_in_unwind() {
|
||||
let arc = Arc::new(Mutex::new(1i));
|
||||
let arc = Arc::new(Mutex::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _ = Thread::scoped(move|| -> () {
|
||||
struct Unwinder {
|
||||
|
@ -134,7 +134,7 @@ mod test {
|
||||
#[test]
|
||||
fn smoke_once() {
|
||||
static O: Once = ONCE_INIT;
|
||||
let mut a = 0i;
|
||||
let mut a = 0;
|
||||
O.call_once(|| a += 1);
|
||||
assert_eq!(a, 1);
|
||||
O.call_once(|| a += 1);
|
||||
|
@ -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
|
||||
/// {
|
||||
@ -437,7 +437,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rw_arc_poison_wr() {
|
||||
let arc = Arc::new(RwLock::new(1i));
|
||||
let arc = Arc::new(RwLock::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _: Result<uint, _> = Thread::scoped(move|| {
|
||||
let _lock = arc2.write().unwrap();
|
||||
@ -448,7 +448,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rw_arc_poison_ww() {
|
||||
let arc = Arc::new(RwLock::new(1i));
|
||||
let arc = Arc::new(RwLock::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _: Result<uint, _> = Thread::scoped(move|| {
|
||||
let _lock = arc2.write().unwrap();
|
||||
@ -459,7 +459,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rw_arc_no_poison_rr() {
|
||||
let arc = Arc::new(RwLock::new(1i));
|
||||
let arc = Arc::new(RwLock::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _: Result<uint, _> = Thread::scoped(move|| {
|
||||
let _lock = arc2.read().unwrap();
|
||||
@ -470,7 +470,7 @@ mod tests {
|
||||
}
|
||||
#[test]
|
||||
fn test_rw_arc_no_poison_rw() {
|
||||
let arc = Arc::new(RwLock::new(1i));
|
||||
let arc = Arc::new(RwLock::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _: Result<uint, _> = Thread::scoped(move|| {
|
||||
let _lock = arc2.read().unwrap();
|
||||
@ -482,7 +482,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rw_arc() {
|
||||
let arc = Arc::new(RwLock::new(0i));
|
||||
let arc = Arc::new(RwLock::new(0));
|
||||
let arc2 = arc.clone();
|
||||
let (tx, rx) = channel();
|
||||
|
||||
@ -520,7 +520,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rw_arc_access_in_unwind() {
|
||||
let arc = Arc::new(RwLock::new(1i));
|
||||
let arc = Arc::new(RwLock::new(1));
|
||||
let arc2 = arc.clone();
|
||||
let _ = Thread::scoped(move|| -> () {
|
||||
struct Unwinder {
|
||||
|
@ -509,7 +509,7 @@ impl Process {
|
||||
// which will wake up the other end at some point, so we just allow this
|
||||
// signal to be coalesced with the pending signals on the pipe.
|
||||
extern fn sigchld_handler(_signum: libc::c_int) {
|
||||
let msg = 1i;
|
||||
let msg = 1;
|
||||
match unsafe {
|
||||
libc::write(WRITE_FD, &msg as *const _ as *const libc::c_void, 1)
|
||||
} {
|
||||
|
@ -162,7 +162,7 @@ mod imp {
|
||||
|
||||
pub static SIGSTKSZ: libc::size_t = 8192;
|
||||
|
||||
pub const SIG_DFL: sighandler_t = 0i as sighandler_t;
|
||||
pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
|
||||
|
||||
// This definition is not as accurate as it could be, {si_addr} is
|
||||
// actually a giant union. Currently we're only interested in that field,
|
||||
@ -214,7 +214,7 @@ mod imp {
|
||||
|
||||
pub const SIGSTKSZ: libc::size_t = 131072;
|
||||
|
||||
pub const SIG_DFL: sighandler_t = 0i as sighandler_t;
|
||||
pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
|
||||
|
||||
pub type sigset_t = u32;
|
||||
|
||||
@ -271,7 +271,7 @@ mod imp {
|
||||
}
|
||||
|
||||
pub unsafe fn make_handler() -> super::Handler {
|
||||
super::Handler { _data: 0i as *mut libc::c_void }
|
||||
super::Handler { _data: 0 as *mut libc::c_void }
|
||||
}
|
||||
|
||||
pub unsafe fn drop_handler(_handler: &mut super::Handler) {
|
||||
|
@ -333,7 +333,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
|
||||
let _c = Cleanup { handle: process, SymCleanup: SymCleanup };
|
||||
|
||||
// And now that we're done with all the setup, do the stack walking!
|
||||
let mut i = 0i;
|
||||
let mut i = 0;
|
||||
try!(write!(w, "stack backtrace:\n"));
|
||||
while StackWalk64(image, process, thread, &mut frame, &mut context,
|
||||
ptr::null_mut(),
|
||||
|
@ -81,7 +81,7 @@ pub unsafe fn make_handler() -> Handler {
|
||||
panic!("failed to reserve stack space for exception handling");
|
||||
}
|
||||
|
||||
Handler { _data: 0i as *mut libc::c_void }
|
||||
Handler { _data: 0 as *mut libc::c_void }
|
||||
}
|
||||
|
||||
pub struct EXCEPTION_RECORD {
|
||||
|
@ -235,7 +235,7 @@ unsafe extern "system" fn on_tls_callback(h: LPVOID,
|
||||
|
||||
unsafe fn run_dtors() {
|
||||
let mut any_run = true;
|
||||
for _ in 0..5i {
|
||||
for _ in 0..5 {
|
||||
if !any_run { break }
|
||||
any_run = false;
|
||||
let dtors = {
|
||||
|
@ -35,9 +35,9 @@
|
||||
//! let x = ("colorless", "green", "ideas", "sleep", "furiously");
|
||||
//! assert_eq!(x.3, "sleep");
|
||||
//!
|
||||
//! let v = (3i, 3i);
|
||||
//! let u = (1i, -5i);
|
||||
//! assert_eq!(v.0 * u.0 + v.1 * u.1, -12i);
|
||||
//! let v = (3, 3);
|
||||
//! let u = (1, -5);
|
||||
//! assert_eq!(v.0 * u.0 + v.1 * u.1, -12);
|
||||
//! ```
|
||||
//!
|
||||
//! Using traits implemented for tuples:
|
||||
@ -45,8 +45,8 @@
|
||||
//! ```
|
||||
//! use std::default::Default;
|
||||
//!
|
||||
//! let a = (1i, 2i);
|
||||
//! let b = (3i, 4i);
|
||||
//! let a = (1, 2);
|
||||
//! let b = (3, 4);
|
||||
//! assert!(a != b);
|
||||
//!
|
||||
//! let c = b.clone();
|
||||
|
@ -21,6 +21,6 @@ mod inner {
|
||||
}
|
||||
|
||||
pub fn foo() {
|
||||
let a = &1i as &inner::Trait;
|
||||
let a = &1 as &inner::Trait;
|
||||
a.f();
|
||||
}
|
||||
|
@ -21,5 +21,5 @@ pub fn leaf<V>(value: V) -> TreeItem<V> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
BTree::<int> { node: leaf(1i) };
|
||||
BTree::<int> { node: leaf(1) };
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ mod other {
|
||||
}
|
||||
|
||||
pub fn foo(){
|
||||
1i+1;
|
||||
1+1;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ use syntax::ptr::P;
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exported_macro { () => (2i) }
|
||||
macro_rules! exported_macro { () => (2) }
|
||||
|
||||
macro_rules! unexported_macro { () => (3i) }
|
||||
macro_rules! unexported_macro { () => (3) }
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
@ -47,7 +47,7 @@ fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
|
||||
if !tts.is_empty() {
|
||||
cx.span_fatal(sp, "make_a_1 takes no arguments");
|
||||
}
|
||||
MacExpr::new(quote_expr!(cx, 1i))
|
||||
MacExpr::new(quote_expr!(cx, 1))
|
||||
}
|
||||
|
||||
// See Issue #15750
|
||||
|
@ -62,7 +62,7 @@ fn maybe_run_test<F>(argv: &[String], name: String, test: F) where F: FnOnce() {
|
||||
}
|
||||
|
||||
fn shift_push() {
|
||||
let mut v1 = repeat(1i).take(30000).collect::<Vec<_>>();
|
||||
let mut v1 = repeat(1).take(30000).collect::<Vec<_>>();
|
||||
let mut v2 = Vec::new();
|
||||
|
||||
while v1.len() > 0 {
|
||||
|
@ -150,16 +150,16 @@ fn mask(dy: int, dx: int, id: uint, p: &Vec<(int, int)>) -> Option<u64> {
|
||||
// (i/5, i%5).
|
||||
fn make_masks() -> Vec<Vec<Vec<u64> > > {
|
||||
let pieces = vec!(
|
||||
vec!((0i,0i),(0,1),(0,2),(0,3),(1,3)),
|
||||
vec!((0i,0i),(0,2),(0,3),(1,0),(1,1)),
|
||||
vec!((0i,0i),(0,1),(0,2),(1,2),(2,1)),
|
||||
vec!((0i,0i),(0,1),(0,2),(1,1),(2,1)),
|
||||
vec!((0i,0i),(0,2),(1,0),(1,1),(2,1)),
|
||||
vec!((0i,0i),(0,1),(0,2),(1,1),(1,2)),
|
||||
vec!((0i,0i),(0,1),(1,1),(1,2),(2,1)),
|
||||
vec!((0i,0i),(0,1),(0,2),(1,0),(1,2)),
|
||||
vec!((0i,0i),(0,1),(0,2),(1,2),(1,3)),
|
||||
vec!((0i,0i),(0,1),(0,2),(0,3),(1,2)));
|
||||
vec!((0,0),(0,1),(0,2),(0,3),(1,3)),
|
||||
vec!((0,0),(0,2),(0,3),(1,0),(1,1)),
|
||||
vec!((0,0),(0,1),(0,2),(1,2),(2,1)),
|
||||
vec!((0,0),(0,1),(0,2),(1,1),(2,1)),
|
||||
vec!((0,0),(0,2),(1,0),(1,1),(2,1)),
|
||||
vec!((0,0),(0,1),(0,2),(1,1),(1,2)),
|
||||
vec!((0,0),(0,1),(1,1),(1,2),(2,1)),
|
||||
vec!((0,0),(0,1),(0,2),(1,0),(1,2)),
|
||||
vec!((0,0),(0,1),(0,2),(1,2),(1,3)),
|
||||
vec!((0,0),(0,1),(0,2),(0,3),(1,2)));
|
||||
|
||||
// To break the central symmetry of the problem, every
|
||||
// transformation must be taken except for one piece (piece 3
|
||||
@ -169,7 +169,7 @@ fn make_masks() -> Vec<Vec<Vec<u64> > > {
|
||||
.map(|(id, p)| transform(p, id != 3))
|
||||
.collect();
|
||||
|
||||
(0i..50).map(|yx| {
|
||||
(0..50).map(|yx| {
|
||||
transforms.iter().enumerate().map(|(id, t)| {
|
||||
t.iter().filter_map(|p| mask(yx / 5, yx % 5, id, p)).collect()
|
||||
}).collect()
|
||||
|
@ -66,9 +66,9 @@ fn parse_opts(argv: Vec<String> ) -> Config {
|
||||
}
|
||||
|
||||
fn stress_task(id: int) {
|
||||
let mut i = 0i;
|
||||
let mut i = 0;
|
||||
loop {
|
||||
let n = 15i;
|
||||
let n = 15;
|
||||
assert_eq!(fib(n), fib(n));
|
||||
i += 1;
|
||||
println!("{}: Completed {} iterations", id, i);
|
||||
|
@ -67,7 +67,7 @@ fn main() {
|
||||
let f32: f32 = 2.5;
|
||||
let f64: f64 = 3.5;
|
||||
_zzz(); // #break
|
||||
if 1i == 1 { _yyy(); }
|
||||
if 1 == 1 { _yyy(); }
|
||||
}
|
||||
|
||||
fn _zzz() {()}
|
||||
|
@ -36,8 +36,8 @@
|
||||
#![omit_gdb_pretty_printer_section]
|
||||
|
||||
fn main() {
|
||||
let a = box 1i;
|
||||
let b = box() (2i, 3.5f64);
|
||||
let a = box 1;
|
||||
let b = box() (2, 3.5f64);
|
||||
|
||||
zzz(); // #break
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
some_generic_fun(0.5f64, 10i);
|
||||
some_generic_fun(&29i, box 110i);
|
||||
some_generic_fun(0.5f64, 10);
|
||||
some_generic_fun(&29, box 110);
|
||||
}
|
||||
|
||||
fn zzz() { () }
|
||||
|
@ -202,7 +202,7 @@ fn main() {
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
for i in 1234..1235i {
|
||||
for i in 1234..1235 {
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ fn main() {
|
||||
let Struct { a: k, b: l } = Struct { a: 12, b: 13 };
|
||||
|
||||
// ignored tuple element
|
||||
let (m, _, n) = (14i, 15i, 16i);
|
||||
let (m, _, n) = (14, 15, 16);
|
||||
|
||||
// ignored struct field
|
||||
let Struct { b: o, .. } = Struct { a: 17, b: 18 };
|
||||
@ -291,25 +291,25 @@ fn main() {
|
||||
|
||||
// complex nesting
|
||||
let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
|
||||
((25i, 26i), ((27i, (28i, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33i);
|
||||
((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
|
||||
|
||||
// reference
|
||||
let &aa = &(34i, 35i);
|
||||
let &aa = &(34, 35);
|
||||
|
||||
// reference
|
||||
let &bb = &(36i, 37i);
|
||||
let &bb = &(36, 37);
|
||||
|
||||
// contained reference
|
||||
let (&cc, _) = (&38i, 39i);
|
||||
let (&cc, _) = (&38, 39);
|
||||
|
||||
// unique pointer
|
||||
let box dd = box() (40i, 41i, 42i);
|
||||
let box dd = box() (40, 41, 42);
|
||||
|
||||
// ref binding
|
||||
let ref ee = (43i, 44i, 45i);
|
||||
let ref ee = (43, 44, 45);
|
||||
|
||||
// ref binding in tuple
|
||||
let (ref ff, gg) = (46i, (47i, 48i));
|
||||
let (ref ff, gg) = (46, (47, 48));
|
||||
|
||||
// ref binding in struct
|
||||
let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
|
||||
|
@ -245,7 +245,7 @@ fn non_immediate_args(a: BigStruct, b: BigStruct) {
|
||||
}
|
||||
|
||||
fn binding(a: i64, b: u64, c: f64) {
|
||||
let x = 0i; // #break
|
||||
let x = 0; // #break
|
||||
::std::old_io::print("")
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ fn non_immediate_args(a: BigStruct, b: BigStruct) {
|
||||
|
||||
#[no_stack_check]
|
||||
fn binding(a: i64, b: u64, c: f64) {
|
||||
let x = 0i;
|
||||
let x = 0;
|
||||
::std::old_io::print("");
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ fn non_immediate_args(a: BigStruct, b: BigStruct) {
|
||||
}
|
||||
|
||||
fn binding(a: i64, b: u64, c: f64) {
|
||||
let x = 0i;
|
||||
let x = 0;
|
||||
}
|
||||
|
||||
fn assignment(mut a: u64, b: u64, c: f64) {
|
||||
|
@ -86,9 +86,9 @@ fn dup_tup<T0: Clone, T1: Clone>(t0: &T0, t1: &T1) -> ((T0, T1), (T1, T0)) {
|
||||
|
||||
fn main() {
|
||||
|
||||
let _ = dup_tup(&1i, &2.5f64);
|
||||
let _ = dup_tup(&1, &2.5f64);
|
||||
let _ = dup_tup(&3.5f64, &4_u16);
|
||||
let _ = dup_tup(&5i, &Struct { a: 6, b: 7.5 });
|
||||
let _ = dup_tup(&5, &Struct { a: 6, b: 7.5 });
|
||||
}
|
||||
|
||||
fn zzz() {()}
|
||||
|
@ -74,7 +74,7 @@
|
||||
#![omit_gdb_pretty_printer_section]
|
||||
|
||||
fn outer<TA: Clone>(a: TA) {
|
||||
inner(a.clone(), 1i);
|
||||
inner(a.clone(), 1);
|
||||
inner(a.clone(), 2.5f64);
|
||||
|
||||
fn inner<TX, TY>(x: TX, y: TY) {
|
||||
@ -83,7 +83,7 @@ fn outer<TA: Clone>(a: TA) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
outer(-1i);
|
||||
outer(-1);
|
||||
outer(-2.5f64);
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ impl Enum {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Struct::static_method(1i, 2i);
|
||||
Enum::static_method(-3i, 4.5f64, 5i);
|
||||
Struct::static_method(1, 2);
|
||||
Enum::static_method(-3, 4.5f64, 5);
|
||||
}
|
||||
|
||||
fn zzz() {()}
|
||||
|
@ -76,7 +76,7 @@ fn main() {
|
||||
// 0b01011001 = 89
|
||||
let case3: Regular<u16, i32, u64> = Case3 { a: 0, b: 6438275382588823897 };
|
||||
|
||||
let univariant = TheOnlyCase { a: -1i };
|
||||
let univariant = TheOnlyCase { a: -1 };
|
||||
|
||||
zzz(); // #break
|
||||
}
|
||||
|
@ -51,12 +51,12 @@ struct AGenericStruct<TKey, TValue> {
|
||||
|
||||
fn main() {
|
||||
|
||||
let int_int = AGenericStruct { key: 0i, value: 1i };
|
||||
let int_float = AGenericStruct { key: 2i, value: 3.5f64 };
|
||||
let float_int = AGenericStruct { key: 4.5f64, value: 5i };
|
||||
let int_int = AGenericStruct { key: 0, value: 1 };
|
||||
let int_float = AGenericStruct { key: 2, value: 3.5f64 };
|
||||
let float_int = AGenericStruct { key: 4.5f64, value: 5 };
|
||||
let float_int_float = AGenericStruct {
|
||||
key: 6.5f64,
|
||||
value: AGenericStruct { key: 7i, value: 8.5f64 },
|
||||
value: AGenericStruct { key: 7, value: 8.5f64 },
|
||||
};
|
||||
|
||||
zzz(); // #break
|
||||
|
@ -90,15 +90,15 @@
|
||||
|
||||
fn main() {
|
||||
|
||||
let range = [1i, 2, 3];
|
||||
let range = [1, 2, 3];
|
||||
|
||||
let x = 1000000i; // wan meeeljen doollaars!
|
||||
let x = 1000000; // wan meeeljen doollaars!
|
||||
|
||||
for &x in range.iter() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = -1i * x;
|
||||
let x = -1 * x;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -138,8 +138,8 @@
|
||||
|
||||
fn main() {
|
||||
|
||||
let x = 999i;
|
||||
let y = -1i;
|
||||
let x = 999;
|
||||
let y = -1;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
@ -148,13 +148,13 @@ fn main() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 1001i;
|
||||
let x = 1001;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 1002i;
|
||||
let y = 1003i;
|
||||
let x = 1002;
|
||||
let y = 1003;
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
} else {
|
||||
@ -170,8 +170,8 @@ fn main() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 1004i;
|
||||
let y = 1005i;
|
||||
let x = 1004;
|
||||
let y = 1005;
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
}
|
||||
|
@ -135,13 +135,13 @@ struct Struct {
|
||||
|
||||
fn main() {
|
||||
|
||||
let shadowed = 231i;
|
||||
let not_shadowed = 232i;
|
||||
let shadowed = 231;
|
||||
let not_shadowed = 232;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
match (233i, 234i) {
|
||||
match (233, 234) {
|
||||
(shadowed, local_to_arm) => {
|
||||
|
||||
zzz(); // #break
|
||||
@ -149,7 +149,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
match (235i, 236i) {
|
||||
match (235, 236) {
|
||||
// with literal
|
||||
(235, shadowed) => {
|
||||
|
||||
@ -186,7 +186,7 @@ fn main() {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match (243i, 244i) {
|
||||
match (243, 244) {
|
||||
(shadowed, ref local_to_arm) => {
|
||||
|
||||
zzz(); // #break
|
||||
|
@ -19,6 +19,6 @@
|
||||
// Nothing to do here really, just make sure it compiles. See issue #8513.
|
||||
fn main() {
|
||||
let _ = |&:|();
|
||||
let _ = (1u..3).map(|_| 5i);
|
||||
let _ = (1u..3).map(|_| 5);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@
|
||||
|
||||
fn main() {
|
||||
|
||||
let mut x = 0i;
|
||||
let mut x = 0;
|
||||
|
||||
loop {
|
||||
if x >= 2 {
|
||||
@ -160,7 +160,7 @@ fn main() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = -987i;
|
||||
let x = -987;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -136,7 +136,7 @@
|
||||
|
||||
fn main() {
|
||||
|
||||
let mut x = 0i;
|
||||
let mut x = 0;
|
||||
|
||||
while x < 2 {
|
||||
zzz(); // #break
|
||||
@ -156,7 +156,7 @@ fn main() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = -987i;
|
||||
let x = -987;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -123,7 +123,7 @@ macro_rules! no_new_scope {
|
||||
|
||||
macro_rules! new_scope {
|
||||
() => ({
|
||||
let a = 890242i;
|
||||
let a = 890242;
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
})
|
||||
@ -151,8 +151,8 @@ macro_rules! dup_expr {
|
||||
|
||||
fn main() {
|
||||
|
||||
let a = trivial!(10i);
|
||||
let b = no_new_scope!(33i);
|
||||
let a = trivial!(10);
|
||||
let b = no_new_scope!(33);
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
@ -162,12 +162,12 @@ fn main() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
shadow_within_macro!(100i);
|
||||
shadow_within_macro!(100);
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let c = dup_expr!(10i * 20);
|
||||
let c = dup_expr!(10 * 20);
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -364,8 +364,8 @@ fn a_function(x: int) -> int {
|
||||
|
||||
fn main() {
|
||||
|
||||
let val = -1i;
|
||||
let ten = 10i;
|
||||
let val = -1;
|
||||
let ten = 10;
|
||||
|
||||
// surrounded by struct expression
|
||||
let point = Point {
|
||||
@ -417,7 +417,7 @@ fn main() {
|
||||
sentinel();
|
||||
|
||||
val
|
||||
}, 0i);
|
||||
}, 0);
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
@ -492,7 +492,7 @@ fn main() {
|
||||
sentinel();
|
||||
|
||||
// index expression
|
||||
let a_vector = [10i; 20];
|
||||
let a_vector = [10; 20];
|
||||
let _ = a_vector[{
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -47,7 +47,7 @@ fn zzz() {()}
|
||||
|
||||
fn some_function(a: int, b: int) {
|
||||
let some_variable = Struct { a: 11, b: 22 };
|
||||
let some_other_variable = 23i;
|
||||
let some_other_variable = 23;
|
||||
|
||||
for x in 0..1 {
|
||||
zzz(); // #break
|
||||
|
@ -48,18 +48,18 @@
|
||||
#![omit_gdb_pretty_printer_section]
|
||||
|
||||
fn function_one() {
|
||||
let abc = 10101i;
|
||||
let abc = 10101;
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
fn function_two() {
|
||||
let abc = 20202i;
|
||||
let abc = 20202;
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
|
||||
fn function_three() {
|
||||
let abc = 30303i;
|
||||
let abc = 30303;
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
|
@ -48,18 +48,18 @@
|
||||
#![omit_gdb_pretty_printer_section]
|
||||
|
||||
fn function_one() {
|
||||
let a = 10101i;
|
||||
let a = 10101;
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
fn function_two() {
|
||||
let b = 20202i;
|
||||
let b = 20202;
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
|
||||
fn function_three() {
|
||||
let c = 30303i;
|
||||
let c = 30303;
|
||||
zzz(); // #break
|
||||
}
|
||||
|
||||
|
@ -103,20 +103,20 @@ fn main() {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 10i;
|
||||
let x = 10;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 10.5f64;
|
||||
let y = 20i;
|
||||
let y = 20;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
{
|
||||
let x = true;
|
||||
let y = 2220i;
|
||||
let y = 2220;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
@ -65,13 +65,13 @@ fn a_function(x: bool, y: bool) {
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 10i;
|
||||
let x = 10;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
||||
let x = 10.5f64;
|
||||
let y = 20i;
|
||||
let y = 20;
|
||||
|
||||
zzz(); // #break
|
||||
sentinel();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user