range(a, b).foo() -> (a..b).foo()

sed -i 's/ range(\([^,]*\), *\([^()]*\))\./ (\1\.\.\2)\./g' **/*.rs
This commit is contained in:
Jorge Aparicio 2015-01-26 15:44:22 -05:00
parent bedd8108dc
commit c300d681bd
55 changed files with 122 additions and 122 deletions

View file

@ -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));
}
});

View file

@ -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|| {

View file

@ -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();

View file

@ -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();

View file

@ -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.

View file

@ -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)
}

View file

@ -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);
}

View file

@ -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

View file

@ -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() {

View file

@ -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);
})

View file

@ -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);

View file

@ -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());
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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);

View file

@ -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<_>>()

View file

@ -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) {

View file

@ -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";

View file

@ -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|| {

View file

@ -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);