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

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