mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
range(a, b).foo()
-> (a..b).foo()
sed -i 's/ range(\([^,]*\), *\([^()]*\))\./ (\1\.\.\2)\./g' **/*.rs
This commit is contained in:
parent
bedd8108dc
commit
c300d681bd
@ -95,7 +95,7 @@ use heap::deallocate;
|
||||
/// use std::thread::Thread;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let numbers: Vec<_> = range(0, 100u32).map(|i| i as f32).collect();
|
||||
/// let numbers: Vec<_> = (0..100u32).map(|i| i as f32).collect();
|
||||
/// let shared_numbers = Arc::new(numbers);
|
||||
///
|
||||
/// for _ in range(0u, 10) {
|
||||
|
@ -70,7 +70,7 @@ pub fn find_rand_n<M, T, I, F>(n: uint,
|
||||
{
|
||||
// setup
|
||||
let mut rng = rand::weak_rng();
|
||||
let mut keys = range(0, n).map(|_| rng.gen::<uint>() % n)
|
||||
let mut keys = (0..n).map(|_| rng.gen::<uint>() % n)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for k in keys.iter() {
|
||||
|
@ -660,7 +660,7 @@ impl Bitv {
|
||||
|
||||
let len = self.nbits/8 +
|
||||
if self.nbits % 8 == 0 { 0 } else { 1 };
|
||||
range(0, len).map(|i|
|
||||
(0..len).map(|i|
|
||||
bit(self, i, 0) |
|
||||
bit(self, i, 1) |
|
||||
bit(self, i, 2) |
|
||||
@ -2283,7 +2283,7 @@ mod tests {
|
||||
|
||||
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools);
|
||||
|
||||
let long = range(0, 10000).map(|i| i % 2 == 0).collect::<Vec<_>>();
|
||||
let long = (0..10000).map(|i| i % 2 == 0).collect::<Vec<_>>();
|
||||
let bitv: Bitv = long.iter().map(|n| *n).collect();
|
||||
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
|
||||
}
|
||||
@ -2647,7 +2647,7 @@ mod bitv_set_test {
|
||||
let idxs: Vec<uint> = bitv.iter().collect();
|
||||
assert_eq!(idxs, vec![0, 2, 3]);
|
||||
|
||||
let long: BitvSet = range(0u, 10000).filter(|&n| n % 2 == 0).collect();
|
||||
let long: BitvSet = (0u..10000).filter(|&n| n % 2 == 0).collect();
|
||||
let real = range_step(0, 10000, 2).collect::<Vec<uint>>();
|
||||
|
||||
let idxs: Vec<uint> = long.iter().collect();
|
||||
|
@ -1661,7 +1661,7 @@ mod test {
|
||||
let size = 10000u;
|
||||
|
||||
// Forwards
|
||||
let mut map: BTreeMap<uint, uint> = range(0, size).map(|i| (i, i)).collect();
|
||||
let mut map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
|
||||
|
||||
fn test<T>(size: uint, mut iter: T) where T: Iterator<Item=(uint, uint)> {
|
||||
for i in range(0, size) {
|
||||
@ -1681,7 +1681,7 @@ mod test {
|
||||
let size = 10000u;
|
||||
|
||||
// Forwards
|
||||
let mut map: BTreeMap<uint, uint> = range(0, size).map(|i| (i, i)).collect();
|
||||
let mut map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
|
||||
|
||||
fn test<T>(size: uint, mut iter: T) where T: Iterator<Item=(uint, uint)> {
|
||||
for i in range(0, size) {
|
||||
@ -1701,7 +1701,7 @@ mod test {
|
||||
let size = 10000u;
|
||||
|
||||
// Forwards
|
||||
let mut map: BTreeMap<uint, uint> = range(0, size).map(|i| (i, i)).collect();
|
||||
let mut map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
|
||||
|
||||
fn test<T>(size: uint, mut iter: T)
|
||||
where T: Iterator<Item=(uint, uint)> + DoubleEndedIterator {
|
||||
@ -1727,7 +1727,7 @@ mod test {
|
||||
let size = 5u;
|
||||
|
||||
// Forwards
|
||||
let map: BTreeMap<uint, uint> = range(0, size).map(|i| (i, i)).collect();
|
||||
let map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
|
||||
|
||||
let mut j = 0u;
|
||||
for ((&k, &v), i) in map.range(Included(&2), Unbounded).zip(range(2u, size)) {
|
||||
@ -1741,11 +1741,11 @@ mod test {
|
||||
#[test]
|
||||
fn test_range_1000() {
|
||||
let size = 1000u;
|
||||
let map: BTreeMap<uint, uint> = range(0, size).map(|i| (i, i)).collect();
|
||||
let map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
|
||||
|
||||
fn test(map: &BTreeMap<uint, uint>, size: uint, min: Bound<&uint>, max: Bound<&uint>) {
|
||||
let mut kvs = map.range(min, max).map(|(&k, &v)| (k, v));
|
||||
let mut pairs = range(0, size).map(|i| (i, i));
|
||||
let mut pairs = (0..size).map(|i| (i, i));
|
||||
|
||||
for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
|
||||
assert_eq!(kv, pair);
|
||||
@ -1764,7 +1764,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_range() {
|
||||
let size = 200u;
|
||||
let map: BTreeMap<uint, uint> = range(0, size).map(|i| (i, i)).collect();
|
||||
let map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
|
||||
|
||||
for i in range(0, size) {
|
||||
for j in range(i, size) {
|
||||
|
@ -1334,7 +1334,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let list: DList<int> = range(0i, 10).collect();
|
||||
let list: DList<int> = (0i..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()
|
||||
|
@ -1828,7 +1828,7 @@ mod tests {
|
||||
|
||||
#[bench]
|
||||
fn bench_iter_1000(b: &mut test::Bencher) {
|
||||
let ring: RingBuf<int> = range(0i, 1000).collect();
|
||||
let ring: RingBuf<int> = (0i..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> = range(0i, 1000).collect();
|
||||
let mut ring: RingBuf<int> = (0i..1000).collect();
|
||||
|
||||
b.iter(|| {
|
||||
let mut sum = 0;
|
||||
@ -1977,7 +1977,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_swap() {
|
||||
let mut d: RingBuf<int> = range(0i, 5).collect();
|
||||
let mut d: RingBuf<int> = (0i..5).collect();
|
||||
d.pop_front();
|
||||
d.swap(0, 3);
|
||||
assert_eq!(d.iter().map(|&x|x).collect::<Vec<int>>(), vec!(4, 2, 3, 1));
|
||||
@ -2309,7 +2309,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let ringbuf: RingBuf<int> = range(0i, 10).collect();
|
||||
let ringbuf: RingBuf<int> = (0i..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()
|
||||
@ -2494,9 +2494,9 @@ mod tests {
|
||||
|
||||
for len in range(0, final_len) {
|
||||
let expected = if back {
|
||||
range(0, len).collect()
|
||||
(0..len).collect()
|
||||
} else {
|
||||
range(0, len).rev().collect()
|
||||
(0..len).rev().collect()
|
||||
};
|
||||
for tail_pos in range(0, usable_cap) {
|
||||
tester.tail = tail_pos;
|
||||
@ -2652,7 +2652,7 @@ mod tests {
|
||||
ring.push_back(i);
|
||||
|
||||
let (left, right) = ring.as_slices();
|
||||
let expected: Vec<_> = range(0, i+1).collect();
|
||||
let expected: Vec<_> = (0..i+1).collect();
|
||||
assert_eq!(left, expected);
|
||||
assert_eq!(right, []);
|
||||
}
|
||||
@ -2660,8 +2660,8 @@ mod tests {
|
||||
for j in range(-last, 0) {
|
||||
ring.push_front(j);
|
||||
let (left, right) = ring.as_slices();
|
||||
let expected_left: Vec<_> = range(-last, j+1).rev().collect();
|
||||
let expected_right: Vec<_> = range(0, first).collect();
|
||||
let expected_left: Vec<_> = (-last..j+1).rev().collect();
|
||||
let expected_right: Vec<_> = (0..first).collect();
|
||||
assert_eq!(left, expected_left);
|
||||
assert_eq!(right, expected_right);
|
||||
}
|
||||
@ -2680,7 +2680,7 @@ mod tests {
|
||||
ring.push_back(i);
|
||||
|
||||
let (left, right) = ring.as_mut_slices();
|
||||
let expected: Vec<_> = range(0, i+1).collect();
|
||||
let expected: Vec<_> = (0..i+1).collect();
|
||||
assert_eq!(left, expected);
|
||||
assert_eq!(right, []);
|
||||
}
|
||||
@ -2688,8 +2688,8 @@ mod tests {
|
||||
for j in range(-last, 0) {
|
||||
ring.push_front(j);
|
||||
let (left, right) = ring.as_mut_slices();
|
||||
let expected_left: Vec<_> = range(-last, j+1).rev().collect();
|
||||
let expected_right: Vec<_> = range(0, first).collect();
|
||||
let expected_left: Vec<_> = (-last..j+1).rev().collect();
|
||||
let expected_right: Vec<_> = (0..first).collect();
|
||||
assert_eq!(left, expected_left);
|
||||
assert_eq!(right, expected_right);
|
||||
}
|
||||
|
@ -1165,7 +1165,7 @@ impl ElementSwaps {
|
||||
// element (equal to the original index).
|
||||
ElementSwaps{
|
||||
emit_reset: true,
|
||||
sdir: range(0, length).map(|i| SizeDirection{ size: i, dir: Neg }).collect(),
|
||||
sdir: (0..length).map(|i| SizeDirection{ size: i, dir: Neg }).collect(),
|
||||
swaps_made: 0
|
||||
}
|
||||
}
|
||||
@ -1526,7 +1526,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_from_fn() {
|
||||
// Test on-stack from_fn.
|
||||
let mut v = range(0, 3).map(square).collect::<Vec<_>>();
|
||||
let mut v = (0..3).map(square).collect::<Vec<_>>();
|
||||
{
|
||||
let v = v.as_slice();
|
||||
assert_eq!(v.len(), 3u);
|
||||
@ -1536,7 +1536,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// Test on-heap from_fn.
|
||||
v = range(0, 5).map(square).collect::<Vec<_>>();
|
||||
v = (0..5).map(square).collect::<Vec<_>>();
|
||||
{
|
||||
let v = v.as_slice();
|
||||
assert_eq!(v.len(), 5u);
|
||||
@ -2134,7 +2134,7 @@ mod tests {
|
||||
// the second item represents which occurrence of that
|
||||
// number this element is, i.e. the second elements
|
||||
// will occur in sorted order.
|
||||
let mut v = range(0, len).map(|_| {
|
||||
let mut v = (0..len).map(|_| {
|
||||
let n = thread_rng().gen::<uint>() % 10;
|
||||
counts[n] += 1;
|
||||
(n, counts[n])
|
||||
@ -2723,7 +2723,7 @@ mod tests {
|
||||
assert_eq!(xs.capacity(), 128);
|
||||
xs.shrink_to_fit();
|
||||
assert_eq!(xs.capacity(), 100);
|
||||
assert_eq!(xs, range(0i, 100i).collect::<Vec<_>>());
|
||||
assert_eq!(xs, (0i..100i).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -2854,7 +2854,7 @@ mod bench {
|
||||
fn iterator(b: &mut Bencher) {
|
||||
// peculiar numbers to stop LLVM from optimising the summation
|
||||
// out.
|
||||
let v = range(0u, 100).map(|i| i ^ (i << 1) ^ (i >> 1)).collect::<Vec<_>>();
|
||||
let v = (0u..100).map(|i| i ^ (i << 1) ^ (i >> 1)).collect::<Vec<_>>();
|
||||
|
||||
b.iter(|| {
|
||||
let mut sum = 0;
|
||||
@ -2882,7 +2882,7 @@ mod bench {
|
||||
#[bench]
|
||||
fn concat(b: &mut Bencher) {
|
||||
let xss: Vec<Vec<uint>> =
|
||||
range(0, 100u).map(|i| range(0, i).collect()).collect();
|
||||
(0..100u).map(|i| (0..i).collect()).collect();
|
||||
b.iter(|| {
|
||||
xss.concat();
|
||||
});
|
||||
@ -2891,7 +2891,7 @@ mod bench {
|
||||
#[bench]
|
||||
fn connect(b: &mut Bencher) {
|
||||
let xss: Vec<Vec<uint>> =
|
||||
range(0, 100u).map(|i| range(0, i).collect()).collect();
|
||||
(0..100u).map(|i| (0..i).collect()).collect();
|
||||
b.iter(|| {
|
||||
xss.connect(&0)
|
||||
});
|
||||
@ -2908,7 +2908,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn starts_with_same_vector(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = range(0, 100).collect();
|
||||
let vec: Vec<uint> = (0..100).collect();
|
||||
b.iter(|| {
|
||||
vec.starts_with(vec.as_slice())
|
||||
})
|
||||
@ -2924,8 +2924,8 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn starts_with_diff_one_element_at_end(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = range(0, 100).collect();
|
||||
let mut match_vec: Vec<uint> = range(0, 99).collect();
|
||||
let vec: Vec<uint> = (0..100).collect();
|
||||
let mut match_vec: Vec<uint> = (0..99).collect();
|
||||
match_vec.push(0);
|
||||
b.iter(|| {
|
||||
vec.starts_with(match_vec.as_slice())
|
||||
@ -2934,7 +2934,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn ends_with_same_vector(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = range(0, 100).collect();
|
||||
let vec: Vec<uint> = (0..100).collect();
|
||||
b.iter(|| {
|
||||
vec.ends_with(vec.as_slice())
|
||||
})
|
||||
@ -2950,8 +2950,8 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn ends_with_diff_one_element_at_beginning(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = range(0, 100).collect();
|
||||
let mut match_vec: Vec<uint> = range(0, 100).collect();
|
||||
let vec: Vec<uint> = (0..100).collect();
|
||||
let mut match_vec: Vec<uint> = (0..100).collect();
|
||||
match_vec.as_mut_slice()[0] = 200;
|
||||
b.iter(|| {
|
||||
vec.starts_with(match_vec.as_slice())
|
||||
@ -2960,7 +2960,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn contains_last_element(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = range(0, 100).collect();
|
||||
let vec: Vec<uint> = (0..100).collect();
|
||||
b.iter(|| {
|
||||
vec.contains(&99u)
|
||||
})
|
||||
@ -3069,7 +3069,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn sort_sorted(b: &mut Bencher) {
|
||||
let mut v = range(0u, 10000).collect::<Vec<_>>();
|
||||
let mut v = (0u..10000).collect::<Vec<_>>();
|
||||
b.iter(|| {
|
||||
v.sort();
|
||||
});
|
||||
@ -3113,7 +3113,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn sort_big_sorted(b: &mut Bencher) {
|
||||
let mut v = range(0, 10000u).map(|i| (i, i, i, i)).collect::<Vec<_>>();
|
||||
let mut v = (0..10000u).map(|i| (i, i, i, i)).collect::<Vec<_>>();
|
||||
b.iter(|| {
|
||||
v.sort();
|
||||
});
|
||||
|
@ -2122,7 +2122,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_chars_decoding() {
|
||||
let mut bytes = [0u8; 4];
|
||||
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
|
||||
for c in (0u32..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
|
||||
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
|
||||
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
|
||||
if Some(c) != s.chars().next() {
|
||||
@ -2134,7 +2134,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_chars_rev_decoding() {
|
||||
let mut bytes = [0u8; 4];
|
||||
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
|
||||
for c in (0u32..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
|
||||
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
|
||||
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
|
||||
if Some(c) != s.chars().rev().next() {
|
||||
|
@ -2442,7 +2442,7 @@ mod tests {
|
||||
b.bytes = src_len as u64;
|
||||
|
||||
b.iter(|| {
|
||||
let dst = range(0, src_len).collect::<Vec<_>>();
|
||||
let dst = (0..src_len).collect::<Vec<_>>();
|
||||
assert_eq!(dst.len(), src_len);
|
||||
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
|
||||
})
|
||||
|
@ -242,7 +242,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
|
||||
if i < 0
|
||||
|| buf[i as uint] == b'-'
|
||||
|| buf[i as uint] == b'+' {
|
||||
for j in range(i as uint + 1, end).rev() {
|
||||
for j in (i as uint + 1..end).rev() {
|
||||
buf[j + 1] = buf[j];
|
||||
}
|
||||
buf[(i + 1) as uint] = value2ascii(1);
|
||||
|
@ -717,7 +717,7 @@ pub trait IteratorExt: Iterator + Sized {
|
||||
Self: ExactSizeIterator + DoubleEndedIterator
|
||||
{
|
||||
let len = self.len();
|
||||
for i in range(0, len).rev() {
|
||||
for i in (0..len).rev() {
|
||||
if predicate(self.next_back().expect("rposition: incorrect ExactSizeIterator")) {
|
||||
return Some(i);
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ impl TwoWaySearcher {
|
||||
|
||||
// See if the left part of the needle matches
|
||||
let start = if long_period { 0 } else { self.memory };
|
||||
for i in range(start, self.crit_pos).rev() {
|
||||
for i in (start..self.crit_pos).rev() {
|
||||
if needle[i] != haystack[self.position + i] {
|
||||
self.position += self.period;
|
||||
if !long_period {
|
||||
|
@ -731,12 +731,12 @@ fn test_random_access_cycle() {
|
||||
#[test]
|
||||
fn test_double_ended_range() {
|
||||
assert!(range(11i, 14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]);
|
||||
for _ in range(10i, 0).rev() {
|
||||
for _ in (10i..0).rev() {
|
||||
panic!("unreachable");
|
||||
}
|
||||
|
||||
assert!(range(11u, 14).rev().collect::<Vec<uint>>() == vec![13u, 12, 11]);
|
||||
for _ in range(10u, 0).rev() {
|
||||
for _ in (10u..0).rev() {
|
||||
panic!("unreachable");
|
||||
}
|
||||
}
|
||||
@ -883,7 +883,7 @@ fn test_fuse() {
|
||||
|
||||
#[bench]
|
||||
fn bench_rposition(b: &mut Bencher) {
|
||||
let it: Vec<uint> = range(0u, 300).collect();
|
||||
let it: Vec<uint> = (0u..300).collect();
|
||||
b.iter(|| {
|
||||
it.iter().rposition(|&x| x <= 150);
|
||||
});
|
||||
@ -900,7 +900,7 @@ fn bench_skip_while(b: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn bench_multiple_take(b: &mut Bencher) {
|
||||
let mut it = range(0u, 42).cycle();
|
||||
let mut it = (0u..42).cycle();
|
||||
b.iter(|| {
|
||||
let n = it.next().unwrap();
|
||||
for _ in range(0u, n) {
|
||||
|
@ -223,13 +223,13 @@ fn test_ord() {
|
||||
/* FIXME(#20575)
|
||||
#[test]
|
||||
fn test_collect() {
|
||||
let v: Option<Vec<int>> = range(0i, 0).map(|_| Some(0i)).collect();
|
||||
let v: Option<Vec<int>> = (0i..0).map(|_| Some(0i)).collect();
|
||||
assert!(v == Some(vec![]));
|
||||
|
||||
let v: Option<Vec<int>> = range(0i, 3).map(|x| Some(x)).collect();
|
||||
let v: Option<Vec<int>> = (0i..3).map(|x| Some(x)).collect();
|
||||
assert!(v == Some(vec![0, 1, 2]));
|
||||
|
||||
let v: Option<Vec<int>> = range(0i, 3).map(|x| {
|
||||
let v: Option<Vec<int>> = (0i..3).map(|x| {
|
||||
if x > 1 { None } else { Some(x) }
|
||||
}).collect();
|
||||
assert!(v == None);
|
||||
|
@ -68,13 +68,13 @@ pub fn test_impl_map_err() {
|
||||
/* FIXME(#20575)
|
||||
#[test]
|
||||
fn test_collect() {
|
||||
let v: Result<Vec<int>, ()> = range(0i, 0).map(|_| Ok::<int, ()>(0)).collect();
|
||||
let v: Result<Vec<int>, ()> = (0i..0).map(|_| Ok::<int, ()>(0)).collect();
|
||||
assert!(v == Ok(vec![]));
|
||||
|
||||
let v: Result<Vec<int>, ()> = range(0i, 3).map(|x| Ok::<int, ()>(x)).collect();
|
||||
let v: Result<Vec<int>, ()> = (0i..3).map(|x| Ok::<int, ()>(x)).collect();
|
||||
assert!(v == Ok(vec![0, 1, 2]));
|
||||
|
||||
let v: Result<Vec<int>, int> = range(0i, 3).map(|x| {
|
||||
let v: Result<Vec<int>, int> = (0i..3).map(|x| {
|
||||
if x > 1 { Err(x) } else { Ok(x) }
|
||||
}).collect();
|
||||
assert!(v == Err(2));
|
||||
|
@ -586,7 +586,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
||||
|
||||
fn f(_x: uint) -> Vec<Optval> { return Vec::new(); }
|
||||
|
||||
let mut vals: Vec<_> = range(0, n_opts).map(f).collect();
|
||||
let mut vals: Vec<_> = (0..n_opts).map(f).collect();
|
||||
let mut free: Vec<String> = Vec::new();
|
||||
let l = args.len();
|
||||
let mut i = 0;
|
||||
|
@ -247,14 +247,14 @@ mod test {
|
||||
let seed : &[_] = &[0u32; 8];
|
||||
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
|
||||
|
||||
let v = range(0, 16).map(|_| ra.next_u32()).collect::<Vec<_>>();
|
||||
let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
|
||||
assert_eq!(v,
|
||||
vec!(0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
|
||||
0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
|
||||
0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
|
||||
0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2));
|
||||
|
||||
let v = range(0, 16).map(|_| ra.next_u32()).collect::<Vec<_>>();
|
||||
let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
|
||||
assert_eq!(v,
|
||||
vec!(0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73,
|
||||
0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32,
|
||||
|
@ -330,7 +330,7 @@ impl Isaac64Rng {
|
||||
if use_rsl {
|
||||
macro_rules! memloop {
|
||||
($arr:expr) => {{
|
||||
for i in range(0, RAND_SIZE_64 / 8).map(|i| i * 8) {
|
||||
for i in (0..RAND_SIZE_64 / 8).map(|i| i * 8) {
|
||||
a+=$arr[i ]; b+=$arr[i+1];
|
||||
c+=$arr[i+2]; d+=$arr[i+3];
|
||||
e+=$arr[i+4]; f+=$arr[i+5];
|
||||
@ -347,7 +347,7 @@ impl Isaac64Rng {
|
||||
memloop!(self.rsl);
|
||||
memloop!(self.mem);
|
||||
} else {
|
||||
for i in range(0, RAND_SIZE_64 / 8).map(|i| i * 8) {
|
||||
for i in (0..RAND_SIZE_64 / 8).map(|i| i * 8) {
|
||||
mix!();
|
||||
self.mem[i ]=a; self.mem[i+1]=b;
|
||||
self.mem[i+2]=c; self.mem[i+3]=d;
|
||||
@ -374,7 +374,7 @@ impl Isaac64Rng {
|
||||
}
|
||||
|
||||
for &(mr_offset, m2_offset) in MP_VEC.iter() {
|
||||
for base in range(0, MIDPOINT / 4).map(|i| i * 4) {
|
||||
for base in (0..MIDPOINT / 4).map(|i| i * 4) {
|
||||
|
||||
macro_rules! rngstepp {
|
||||
($j:expr, $shift:expr) => {{
|
||||
@ -573,7 +573,7 @@ mod test {
|
||||
let seed: &[_] = &[1, 23, 456, 7890, 12345];
|
||||
let mut ra: IsaacRng = SeedableRng::from_seed(seed);
|
||||
// Regression test that isaac is actually using the above vector
|
||||
let v = range(0, 10).map(|_| ra.next_u32()).collect::<Vec<_>>();
|
||||
let v = (0..10).map(|_| ra.next_u32()).collect::<Vec<_>>();
|
||||
assert_eq!(v,
|
||||
vec!(2558573138, 873787463, 263499565, 2103644246, 3595684709,
|
||||
4203127393, 264982119, 2765226902, 2737944514, 3900253796));
|
||||
@ -583,7 +583,7 @@ mod test {
|
||||
// skip forward to the 10000th number
|
||||
for _ in range(0u, 10000) { rb.next_u32(); }
|
||||
|
||||
let v = range(0, 10).map(|_| rb.next_u32()).collect::<Vec<_>>();
|
||||
let v = (0..10).map(|_| rb.next_u32()).collect::<Vec<_>>();
|
||||
assert_eq!(v,
|
||||
vec!(3676831399, 3183332890, 2834741178, 3854698763, 2717568474,
|
||||
1576568959, 3507990155, 179069555, 141456972, 2478885421));
|
||||
@ -593,7 +593,7 @@ mod test {
|
||||
let seed: &[_] = &[1, 23, 456, 7890, 12345];
|
||||
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
|
||||
// Regression test that isaac is actually using the above vector
|
||||
let v = range(0, 10).map(|_| ra.next_u64()).collect::<Vec<_>>();
|
||||
let v = (0..10).map(|_| ra.next_u64()).collect::<Vec<_>>();
|
||||
assert_eq!(v,
|
||||
vec!(547121783600835980, 14377643087320773276, 17351601304698403469,
|
||||
1238879483818134882, 11952566807690396487, 13970131091560099343,
|
||||
@ -605,7 +605,7 @@ mod test {
|
||||
// skip forward to the 10000th number
|
||||
for _ in range(0u, 10000) { rb.next_u64(); }
|
||||
|
||||
let v = range(0, 10).map(|_| rb.next_u64()).collect::<Vec<_>>();
|
||||
let v = (0..10).map(|_| rb.next_u64()).collect::<Vec<_>>();
|
||||
assert_eq!(v,
|
||||
vec!(18143823860592706164, 8491801882678285927, 2699425367717515619,
|
||||
17196852593171130876, 2606123525235546165, 15790932315217671084,
|
||||
|
@ -1184,7 +1184,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
pub fn vuint_at_A_aligned(b: &mut Bencher) {
|
||||
let data = range(0, 4*100).map(|i| {
|
||||
let data = (0..4*100).map(|i| {
|
||||
match i % 2 {
|
||||
0 => 0x80u8,
|
||||
_ => i as u8,
|
||||
@ -1202,7 +1202,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
pub fn vuint_at_A_unaligned(b: &mut Bencher) {
|
||||
let data = range(0, 4*100+1).map(|i| {
|
||||
let data = (0..4*100+1).map(|i| {
|
||||
match i % 2 {
|
||||
1 => 0x80u8,
|
||||
_ => i as u8
|
||||
@ -1220,7 +1220,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
pub fn vuint_at_D_aligned(b: &mut Bencher) {
|
||||
let data = range(0, 4*100).map(|i| {
|
||||
let data = (0..4*100).map(|i| {
|
||||
match i % 4 {
|
||||
0 => 0x10u8,
|
||||
3 => i as u8,
|
||||
@ -1239,7 +1239,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
pub fn vuint_at_D_unaligned(b: &mut Bencher) {
|
||||
let data = range(0, 4*100+1).map(|i| {
|
||||
let data = (0..4*100+1).map(|i| {
|
||||
match i % 4 {
|
||||
1 => 0x10u8,
|
||||
0 => i as u8,
|
||||
|
@ -1598,7 +1598,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
|
||||
F: FnMut(&mut SeekableMemWriter, &T),
|
||||
T: Hash<SipHasher>,
|
||||
{
|
||||
let mut buckets: Vec<Vec<entry<T>>> = range(0, 256u16).map(|_| Vec::new()).collect();
|
||||
let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
|
||||
for elt in index.into_iter() {
|
||||
let mut s = SipHasher::new();
|
||||
elt.val.hash(&mut s);
|
||||
|
@ -70,7 +70,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
|
||||
|
||||
let column_count = m.iter().map(|row| row.len()).max().unwrap_or(0u);
|
||||
assert!(m.iter().all(|row| row.len() == column_count));
|
||||
let column_widths: Vec<uint> = range(0, column_count).map(|col| {
|
||||
let column_widths: Vec<uint> = (0..column_count).map(|col| {
|
||||
pretty_printed_matrix.iter().map(|row| row[col].len()).max().unwrap_or(0u)
|
||||
}).collect();
|
||||
|
||||
@ -609,7 +609,7 @@ fn is_useful(cx: &MatchCheckCtxt,
|
||||
let arity = constructor_arity(cx, &c, left_ty);
|
||||
let mut result = {
|
||||
let pat_slice = &pats[];
|
||||
let subpats: Vec<_> = range(0, arity).map(|i| {
|
||||
let subpats: Vec<_> = (0..arity).map(|i| {
|
||||
pat_slice.get(i).map_or(DUMMY_WILD_PAT, |p| &**p)
|
||||
}).collect();
|
||||
vec![construct_witness(cx, &c, subpats, left_ty)]
|
||||
|
@ -1343,7 +1343,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||
let mut new_lts = Vec::new();
|
||||
if data.lifetimes.len() == 0 {
|
||||
// traverse once to see if there's a need to insert lifetime
|
||||
let need_insert = range(0, expected).any(|i| {
|
||||
let need_insert = (0..expected).any(|i| {
|
||||
indexes.contains(&i)
|
||||
});
|
||||
if need_insert {
|
||||
|
@ -828,7 +828,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn next_ty_vars(&self, n: uint) -> Vec<Ty<'tcx>> {
|
||||
range(0, n).map(|_i| self.next_ty_var()).collect()
|
||||
(0..n).map(|_i| self.next_ty_var()).collect()
|
||||
}
|
||||
|
||||
pub fn next_int_var_id(&self) -> IntVid {
|
||||
|
@ -2473,7 +2473,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
|
||||
// FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx.
|
||||
fn err_args<'tcx>(tcx: &ty::ctxt<'tcx>, len: uint) -> Vec<Ty<'tcx>> {
|
||||
range(0, len).map(|_| tcx.types.err).collect()
|
||||
(0..len).map(|_| tcx.types.err).collect()
|
||||
}
|
||||
|
||||
fn write_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
|
@ -1775,11 +1775,11 @@ mod test_map {
|
||||
for _ in half {}
|
||||
|
||||
DROP_VECTOR.with(|v| {
|
||||
let nk = range(0u, 100).filter(|&i| {
|
||||
let nk = (0u..100).filter(|&i| {
|
||||
v.borrow()[i] == 1
|
||||
}).count();
|
||||
|
||||
let nv = range(0u, 100).filter(|&i| {
|
||||
let nv = (0u..100).filter(|&i| {
|
||||
v.borrow()[i+100] == 1
|
||||
}).count();
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ mod test_set {
|
||||
|
||||
#[test]
|
||||
fn test_drain() {
|
||||
let mut s: HashSet<int> = range(1, 100).collect();
|
||||
let mut s: HashSet<int> = (1..100).collect();
|
||||
|
||||
// try this a bunch of times to make sure we don't screw up internal state.
|
||||
for _ in range(0i, 20) {
|
||||
|
@ -1001,7 +1001,7 @@ mod tests {
|
||||
fn test_pow() {
|
||||
fn naive_pow<T: Int>(base: T, exp: uint) -> T {
|
||||
let one: T = Int::one();
|
||||
range(0, exp).fold(one, |acc, _| acc * base)
|
||||
(0..exp).fold(one, |acc, _| acc * base)
|
||||
}
|
||||
macro_rules! assert_pow {
|
||||
(($num:expr, $exp:expr) => $expected:expr) => {{
|
||||
@ -1028,7 +1028,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn bench_pow_function(b: &mut Bencher) {
|
||||
let v = range(0, 1024u).collect::<Vec<_>>();
|
||||
let v = (0..1024u).collect::<Vec<_>>();
|
||||
b.iter(|| {v.iter().fold(0u, |old, new| old.pow(*new));});
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ mod bench {
|
||||
({
|
||||
use super::u64_from_be_bytes;
|
||||
|
||||
let data = range(0u8, $stride*100+$start_index).collect::<Vec<_>>();
|
||||
let data = (0u8..$stride*100+$start_index).collect::<Vec<_>>();
|
||||
let mut sum = 0u64;
|
||||
$b.iter(|| {
|
||||
let mut i = $start_index;
|
||||
|
@ -617,7 +617,7 @@ unsafe fn load_argc_and_argv(argc: int,
|
||||
argv: *const *const c_char) -> Vec<Vec<u8>> {
|
||||
use iter::range;
|
||||
|
||||
range(0, argc as uint).map(|i| {
|
||||
(0..argc as uint).map(|i| {
|
||||
ffi::c_str_to_bytes(&*argv.offset(i as int)).to_vec()
|
||||
}).collect()
|
||||
}
|
||||
@ -717,7 +717,7 @@ fn real_args() -> Vec<String> {
|
||||
let lpCmdLine = unsafe { GetCommandLineW() };
|
||||
let szArgList = unsafe { CommandLineToArgvW(lpCmdLine, lpArgCount) };
|
||||
|
||||
let args: Vec<_> = range(0, nArgs as uint).map(|i| unsafe {
|
||||
let args: Vec<_> = (0..nArgs as uint).map(|i| unsafe {
|
||||
// Determine the length of this argument.
|
||||
let ptr = *szArgList.offset(i as int);
|
||||
let mut len = 0;
|
||||
|
@ -176,7 +176,7 @@
|
||||
//! }
|
||||
//!
|
||||
//! fn free_doors(blocked: &[uint]) -> Vec<uint> {
|
||||
//! range(0, 3).filter(|x| !blocked.contains(x)).collect()
|
||||
//! (0u..3).filter(|x| !blocked.contains(x)).collect()
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
@ -601,7 +601,7 @@ mod test {
|
||||
let max_val = 100i;
|
||||
|
||||
let mut r = thread_rng();
|
||||
let vals = range(min_val, max_val).collect::<Vec<int>>();
|
||||
let vals = (min_val..max_val).collect::<Vec<int>>();
|
||||
let small_sample = sample(&mut r, vals.iter(), 5);
|
||||
let large_sample = sample(&mut r, vals.iter(), vals.len() + 5);
|
||||
|
||||
|
@ -97,7 +97,7 @@ mod imp {
|
||||
|
||||
unsafe fn load_argc_and_argv(argc: int, argv: *const *const u8) -> Vec<Vec<u8>> {
|
||||
let argv = argv as *const *const libc::c_char;
|
||||
range(0, argc as uint).map(|i| {
|
||||
(0..argc as uint).map(|i| {
|
||||
ffi::c_str_to_bytes(&*argv.offset(i as int)).to_vec()
|
||||
}).collect()
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ impl<T: Send> Packet<T> {
|
||||
tail: ptr::null_mut(),
|
||||
},
|
||||
buf: Buffer {
|
||||
buf: range(0, cap + if cap == 0 {1} else {0}).map(|_| None).collect(),
|
||||
buf: (0..cap + if cap == 0 {1} else {0}).map(|_| None).collect(),
|
||||
start: 0,
|
||||
size: 0,
|
||||
},
|
||||
|
@ -126,7 +126,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
|
||||
let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint};
|
||||
|
||||
// skipping the first one as it is write itself
|
||||
let iter = range(1, cnt).map(|i| {
|
||||
let iter = (1..cnt).map(|i| {
|
||||
print(w, i as int, buf[i])
|
||||
});
|
||||
result::fold(iter, (), |_, _| ())
|
||||
|
@ -166,7 +166,7 @@ pub fn count_names(ms: &[TokenTree]) -> usize {
|
||||
pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: BytePos)
|
||||
-> Box<MatcherPos> {
|
||||
let match_idx_hi = count_names(&ms[]);
|
||||
let matches: Vec<_> = range(0, match_idx_hi).map(|_| Vec::new()).collect();
|
||||
let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect();
|
||||
box MatcherPos {
|
||||
stack: vec![],
|
||||
top_elts: TtSeq(ms),
|
||||
|
@ -939,7 +939,7 @@ mod bench {
|
||||
#[bench]
|
||||
pub fn sum_many_f64(b: &mut Bencher) {
|
||||
let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60];
|
||||
let v = range(0, 500).map(|i| nums[i%5]).collect::<Vec<_>>();
|
||||
let v = (0..500).map(|i| nums[i%5]).collect::<Vec<_>>();
|
||||
|
||||
b.iter(|| {
|
||||
v.sum();
|
||||
|
@ -62,13 +62,13 @@ fn descending<M: MutableMap>(map: &mut M, n_keys: uint) {
|
||||
println!(" Descending integers:");
|
||||
|
||||
timed("insert", || {
|
||||
for i in range(0, n_keys).rev() {
|
||||
for i in (0..n_keys).rev() {
|
||||
map.insert(i, i + 1);
|
||||
}
|
||||
});
|
||||
|
||||
timed("search", || {
|
||||
for i in range(0, n_keys).rev() {
|
||||
for i in (0..n_keys).rev() {
|
||||
assert_eq!(map.find(&i).unwrap(), &(i + 1));
|
||||
}
|
||||
});
|
||||
|
@ -97,7 +97,7 @@ impl Perm {
|
||||
*place = i as i32 + 1;
|
||||
}
|
||||
|
||||
for i in range(1, self.n as uint).rev() {
|
||||
for i in (1..self.n as uint).rev() {
|
||||
let d = idx / self.fact[i] as i32;
|
||||
self.cnt[i] = d;
|
||||
idx %= self.fact[i] as i32;
|
||||
@ -161,7 +161,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
||||
let mut futures = vec![];
|
||||
let k = perm.max() / N;
|
||||
|
||||
for (_, j) in range(0, N).zip(iter::count(0, k)) {
|
||||
for (_, j) in (0..N).zip(iter::count(0, k)) {
|
||||
let max = cmp::min(j+k, perm.max());
|
||||
|
||||
futures.push(Thread::scoped(move|| {
|
||||
|
@ -135,7 +135,7 @@ struct Items<'a> {
|
||||
impl Table {
|
||||
fn new() -> Table {
|
||||
Table {
|
||||
items: range(0, TABLE_SIZE).map(|_| None).collect()
|
||||
items: (0..TABLE_SIZE).map(|_| None).collect()
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ fn main() {
|
||||
};
|
||||
let input = Arc::new(input);
|
||||
|
||||
let nb_freqs: Vec<_> = range(1u, 3).map(|i| {
|
||||
let nb_freqs: Vec<_> = (1u..3).map(|i| {
|
||||
let input = input.clone();
|
||||
(i, Thread::scoped(move|| generate_frequencies(input.as_slice(), i)))
|
||||
}).collect();
|
||||
|
@ -80,7 +80,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
|
||||
let mut precalc_r = Vec::with_capacity(w);
|
||||
let mut precalc_i = Vec::with_capacity(h);
|
||||
|
||||
let precalc_futures = range(0, WORKERS).map(|i| {
|
||||
let precalc_futures = (0..WORKERS).map(|i| {
|
||||
Thread::scoped(move|| {
|
||||
let mut rs = Vec::with_capacity(w / WORKERS);
|
||||
let mut is = Vec::with_capacity(w / WORKERS);
|
||||
@ -118,7 +118,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
|
||||
let arc_init_r = Arc::new(precalc_r);
|
||||
let arc_init_i = Arc::new(precalc_i);
|
||||
|
||||
let data = range(0, WORKERS).map(|i| {
|
||||
let data = (0..WORKERS).map(|i| {
|
||||
let vec_init_r = arc_init_r.clone();
|
||||
let vec_init_i = arc_init_i.clone();
|
||||
|
||||
|
@ -169,7 +169,7 @@ fn make_masks() -> Vec<Vec<Vec<u64> > > {
|
||||
.map(|(id, p)| transform(p, id != 3))
|
||||
.collect();
|
||||
|
||||
range(0i, 50).map(|yx| {
|
||||
(0i..50).map(|yx| {
|
||||
transforms.iter().enumerate().map(|(id, t)| {
|
||||
t.iter().filter_map(|p| mask(yx / 5, yx % 5, id, p)).collect()
|
||||
}).collect()
|
||||
@ -297,7 +297,7 @@ fn search(
|
||||
let masks_at = &masks[i];
|
||||
|
||||
// for every unused piece
|
||||
for id in range(0u, 10).filter(|&id| board & (1 << (id + 50)) == 0) {
|
||||
for id in (0u..10).filter(|&id| board & (1 << (id + 50)) == 0) {
|
||||
// for each mask that fits on the board
|
||||
for m in masks_at[id].iter().filter(|&m| board & *m == 0) {
|
||||
// This check is too costly.
|
||||
|
@ -49,8 +49,8 @@ impl Sudoku {
|
||||
}
|
||||
|
||||
pub fn from_vec(vec: &[[u8;9];9]) -> Sudoku {
|
||||
let g = range(0, 9u).map(|i| {
|
||||
range(0, 9u).map(|j| { vec[i][j] }).collect()
|
||||
let g = (0..9u).map(|i| {
|
||||
(0..9u).map(|j| { vec[i][j] }).collect()
|
||||
}).collect();
|
||||
return Sudoku::new(g)
|
||||
}
|
||||
|
@ -19,6 +19,6 @@
|
||||
// Nothing to do here really, just make sure it compiles. See issue #8513.
|
||||
fn main() {
|
||||
let _ = |&:|();
|
||||
let _ = range(1u,3).map(|_| 5i);
|
||||
let _ = (1u..3).map(|_| 5i);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ fn main() {
|
||||
let _ = write!(&mut File::create(&main_file).unwrap(),
|
||||
"#![feature(non_ascii_idents)] fn main() {{ {} }}",
|
||||
// random string of length n
|
||||
range(0, n).map(|_| random_char()).collect::<String>());
|
||||
(0..n).map(|_| random_char()).collect::<String>());
|
||||
}
|
||||
|
||||
// rustc is passed to us with --out-dir and -L etc., so we
|
||||
|
@ -26,7 +26,7 @@ fn add_int(x: &mut Ints, v: int) {
|
||||
|
||||
fn iter_ints<F>(x: &Ints, mut f: F) -> bool where F: FnMut(&int) -> bool {
|
||||
let l = x.values.len();
|
||||
range(0u, l).all(|i| f(&x.values[i]))
|
||||
(0u..l).all(|i| f(&x.values[i]))
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
@ -41,7 +41,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
range(0u, 100).map(|_| {
|
||||
(0u..100).map(|_| {
|
||||
Thread::scoped(move|| {
|
||||
assert_eq!(count(5), 16);
|
||||
})
|
||||
|
@ -38,7 +38,7 @@ fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
range(0, 10u).map(|i| {
|
||||
(0..10u).map(|i| {
|
||||
Thread::scoped(move|| {
|
||||
let result = count(5);
|
||||
println!("result = {}", result);
|
||||
|
@ -11,5 +11,5 @@
|
||||
use std::iter::AdditiveIterator;
|
||||
fn main() {
|
||||
let x: [u64; 3] = [1, 2, 3];
|
||||
assert_eq!(6, range(0, 3).map(|i| x[i]).sum());
|
||||
assert_eq!(6, (0..3).map(|i| x[i]).sum());
|
||||
}
|
||||
|
@ -19,5 +19,5 @@ fn uint_to_foo(_: uint) -> Foo {
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
fn main() {
|
||||
range(0u, 10).map(uint_to_foo);
|
||||
(0u..10).map(uint_to_foo);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ impl methods for () {
|
||||
// the position of this function is significant! - if it comes before methods
|
||||
// then it works, if it comes after it then it doesn't!
|
||||
fn to_bools(bitv: Storage) -> Vec<bool> {
|
||||
range(0, 8).map(|i| {
|
||||
(0..8).map(|i| {
|
||||
let w = i / 64;
|
||||
let b = i % 64;
|
||||
let x = 1u64 & (bitv.storage[w] >> b);
|
||||
|
@ -153,7 +153,7 @@ unsafe fn test_triangle() -> bool {
|
||||
// Test 3: turn triangle into a square, bottom to top.
|
||||
unsafe fn test_3(ascend: &mut [*mut u8]) {
|
||||
let new_size = idx_to_size(COUNT-1);
|
||||
for i in range(0u, COUNT / 2).rev() {
|
||||
for i in (0u..COUNT / 2).rev() {
|
||||
let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
|
||||
assert!(old_size < new_size);
|
||||
|
||||
@ -168,7 +168,7 @@ unsafe fn test_triangle() -> bool {
|
||||
// Test 4: turn the square back into a triangle, bottom to top.
|
||||
unsafe fn test_4(ascend: &mut [*mut u8]) {
|
||||
let old_size = idx_to_size(COUNT-1);
|
||||
for i in range(0u, COUNT / 2).rev() {
|
||||
for i in (0u..COUNT / 2).rev() {
|
||||
let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
|
||||
assert!(new_size < old_size);
|
||||
|
||||
|
@ -36,7 +36,7 @@ fn start(argc: int, argv: *const *const u8) -> int {
|
||||
}
|
||||
|
||||
let args = unsafe {
|
||||
range(0, argc as uint).map(|i| {
|
||||
(0..argc as uint).map(|i| {
|
||||
let ptr = *argv.offset(i as int) as *const _;
|
||||
ffi::c_str_to_bytes(&ptr).to_vec()
|
||||
}).collect::<Vec<_>>()
|
||||
|
@ -34,7 +34,7 @@ fn test() {
|
||||
|
||||
let (srv_tx, srv_rx) = channel();
|
||||
let (cli_tx, cli_rx) = channel();
|
||||
let _t = range(0, N).map(|_| {
|
||||
let _t = (0..N).map(|_| {
|
||||
let a = a.clone();
|
||||
let cnt = cnt.clone();
|
||||
let srv_tx = srv_tx.clone();
|
||||
@ -55,7 +55,7 @@ fn test() {
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let _t = range(0, N).map(|_| {
|
||||
let _t = (0..N).map(|_| {
|
||||
let cli_tx = cli_tx.clone();
|
||||
Thread::scoped(move|| {
|
||||
for _ in range(0, M) {
|
||||
|
@ -21,11 +21,11 @@ static CONSTEXPR: TestStruct = TestStruct{x: &413 as *const _};
|
||||
|
||||
|
||||
pub fn main() {
|
||||
let x: Vec<_> = range(0u, 5).collect();
|
||||
let x: Vec<_> = (0u..5).collect();
|
||||
let expected: &[uint] = &[0,1,2,3,4];
|
||||
assert_eq!(x.as_slice(), expected);
|
||||
|
||||
let x = range(0u, 5).collect::<Vec<_>>();
|
||||
let x = (0u..5).collect::<Vec<_>>();
|
||||
assert_eq!(x.as_slice(), expected);
|
||||
|
||||
let y: _ = "hello";
|
||||
|
@ -22,7 +22,7 @@ pub fn main() {
|
||||
let (tx, rx) = channel();
|
||||
let n = 100u;
|
||||
let mut expected = 0u;
|
||||
let _t = range(0u, n).map(|i| {
|
||||
let _t = (0u..n).map(|i| {
|
||||
expected += i;
|
||||
let tx = tx.clone();
|
||||
Thread::scoped(move|| {
|
||||
|
@ -55,7 +55,7 @@ fn find_zombies() { }
|
||||
fn main() {
|
||||
let too_long = format!("/NoSuchCommand{:0300}", 0u8);
|
||||
|
||||
let _failures = range(0, 100).map(|_| {
|
||||
let _failures = (0..100).map(|_| {
|
||||
let cmd = Command::new(too_long.as_slice());
|
||||
let failed = cmd.spawn();
|
||||
assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user