Skip to content

Remove the std::num::Times trait #11672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ syn keyword rustTrait FromStr
syn keyword rustTrait FromIterator Extendable
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
syn keyword rustTrait Times

syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
syn keyword rustTrait Bitwise Bounded Integer Fractional Real RealExt
Expand Down
16 changes: 8 additions & 8 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,19 +770,19 @@ mod tests {

task::spawn(proc() {
arc2.write(|num| {
10.times(|| {
for _ in range(0, 10) {
let tmp = *num;
*num = -1;
task::deschedule();
*num = tmp + 1;
});
}
c.send(());
})
});

// Readers try to catch the writer in the act
let mut children = ~[];
5.times(|| {
for _ in range(0, 5) {
let arc3 = arc.clone();
let mut builder = task::task();
children.push(builder.future_result());
Expand All @@ -791,7 +791,7 @@ mod tests {
assert!(*num >= 0);
})
});
});
}

// Wait for children to pass their asserts
for r in children.mut_iter() {
Expand Down Expand Up @@ -836,7 +836,7 @@ mod tests {

// Reader tasks
let mut reader_convos = ~[];
10.times(|| {
for _ in range(0, 10) {
let ((rp1, rc1), (rp2, rc2)) = (Chan::new(), Chan::new());
reader_convos.push((rc1, rp2));
let arcn = arc.clone();
Expand All @@ -847,7 +847,7 @@ mod tests {
rc2.send(());
})
});
});
}

// Writer task
let arc2 = arc.clone();
Expand Down Expand Up @@ -944,7 +944,7 @@ mod tests {
read_mode.read(|state| {
// if writer mistakenly got in, make sure it mutates state
// before we assert on it
5.times(|| task::deschedule());
for _ in range(0, 5) { task::deschedule(); }
// make sure writer didn't get in.
assert!(*state);
})
Expand All @@ -956,6 +956,6 @@ mod tests {
// helped to expose the race nearly 100% of the time... but adding
// deschedules in the intuitively-right locations made it even less likely,
// and I wasn't sure why :( . This is a mediocre "next best" option.
8.times(|| test_rw_write_cond_downgrade_read_race_helper());
for _ in range(0, 8) { test_rw_write_cond_downgrade_read_race_helper(); }
}
}
4 changes: 2 additions & 2 deletions src/libextra/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ mod test {
use std::rand::{task_rng, random, Rng};
use std::vec;

1000.times(|| {
for _ in range(0, 1000) {
let times = task_rng().gen_range(1u, 100);
let v = vec::from_fn(times, |_| random::<u8>());
assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v);
})
}
}

#[bench]
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ mod test {
// Rendezvous streams should be able to handle any number of messages being sent
let (port, chan) = rendezvous();
spawn(proc() {
10000.times(|| { chan.send(()) })
for _ in range(0, 10000) { chan.send(()); }
});
10000.times(|| { port.recv() })
for _ in range(0, 10000) { port.recv(); }
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,11 @@ mod tests {

#[test]
fn test_fuzz() {
25.times(|| {
for _ in range(0, 25) {
fuzz_test(3);
fuzz_test(16);
fuzz_test(189);
})
}
}

#[cfg(test)]
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,9 @@ pub mod groups {
// here we just need to indent the start of the description
let rowlen = row.char_len();
if rowlen < 24 {
(24 - rowlen).times(|| {
row.push_char(' ')
})
for _ in range(0, 24 - rowlen) {
row.push_char(' ');
}
} else {
row.push_str(desc_sep)
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn escape_str(s: &str) -> ~str {

fn spaces(n: uint) -> ~str {
let mut ss = ~"";
n.times(|| ss.push_str(" "));
for _ in range(0, n) { ss.push_str(" "); }
return ss;
}

Expand Down
16 changes: 8 additions & 8 deletions src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2052,22 +2052,22 @@ mod biguint_tests {
fn test_rand_range() {
let mut rng = task_rng();

10.times(|| {
for _ in range(0, 10) {
assert_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(),
&FromPrimitive::from_uint(237).unwrap()),
FromPrimitive::from_uint(236).unwrap());
});
}

let l = FromPrimitive::from_uint(403469000 + 2352).unwrap();
let u = FromPrimitive::from_uint(403469000 + 3513).unwrap();
1000.times(|| {
for _ in range(0, 1000) {
let n: BigUint = rng.gen_biguint_below(&u);
assert!(n < u);

let n: BigUint = rng.gen_biguint_range(&l, &u);
assert!(n >= l);
assert!(n < u);
})
}
}

#[test]
Expand Down Expand Up @@ -2550,19 +2550,19 @@ mod bigint_tests {
fn test_rand_range() {
let mut rng = task_rng();

10.times(|| {
for _ in range(0, 10) {
assert_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(),
&FromPrimitive::from_uint(237).unwrap()),
FromPrimitive::from_uint(236).unwrap());
});
}

fn check(l: BigInt, u: BigInt) {
let mut rng = task_rng();
1000.times(|| {
for _ in range(0, 1000) {
let n: BigInt = rng.gen_bigint_range(&l, &u);
assert!(n >= l);
assert!(n < u);
});
}
}
let l: BigInt = FromPrimitive::from_uint(403469000 + 2352).unwrap();
let u: BigInt = FromPrimitive::from_uint(403469000 + 3513).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ mod tests {
fn bench_grow(b: &mut test::BenchHarness) {
let mut deq = RingBuf::new();
b.iter(|| {
65.times(|| {
for _ in range(0, 65) {
deq.push_front(1);
})
}
})
}

Expand Down
46 changes: 23 additions & 23 deletions src/libextra/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl<Q:Send> Sem<Q> {
}
});
// Uncomment if you wish to test for sem races. Not valgrind-friendly.
/* 1000.times(|| task::deschedule()); */
/* for _ in range(0, 1000) { task::deschedule(); } */
// Need to wait outside the exclusive.
if waiter_nobe.is_some() {
let _ = waiter_nobe.unwrap().recv();
Expand Down Expand Up @@ -155,7 +155,7 @@ impl Sem<~[WaitQueue]> {
fn new_and_signal(count: int, num_condvars: uint)
-> Sem<~[WaitQueue]> {
let mut queues = ~[];
num_condvars.times(|| queues.push(WaitQueue::new()));
for _ in range(0, num_condvars) { queues.push(WaitQueue::new()); }
Sem::new(count, queues)
}
}
Expand Down Expand Up @@ -691,7 +691,7 @@ impl<'a> RWLockReadMode<'a> {
/// use extra::sync::Barrier;
///
/// let barrier = Barrier::new(10);
/// 10.times(|| {
/// for _ in range(0, 10) {
/// let c = barrier.clone();
/// // The same messages will be printed together.
/// // You will NOT see any interleaving.
Expand All @@ -700,7 +700,7 @@ impl<'a> RWLockReadMode<'a> {
/// c.wait();
/// println!("after wait");
/// });
/// });
/// }
/// ```
#[deriving(Clone)]
pub struct Barrier {
Expand Down Expand Up @@ -780,11 +780,11 @@ mod tests {
let s2 = s.clone();
task::spawn(proc() {
s2.access(|| {
5.times(|| { task::deschedule(); })
for _ in range(0, 5) { task::deschedule(); }
})
});
s.access(|| {
5.times(|| { task::deschedule(); })
for _ in range(0, 5) { task::deschedule(); }
})
}
#[test]
Expand All @@ -797,7 +797,7 @@ mod tests {
s2.acquire();
c.send(());
});
5.times(|| { task::deschedule(); });
for _ in range(0, 5) { task::deschedule(); }
s.release();
let _ = p.recv();

Expand All @@ -806,7 +806,7 @@ mod tests {
let s = Semaphore::new(0);
let s2 = s.clone();
task::spawn(proc() {
5.times(|| { task::deschedule(); });
for _ in range(0, 5) { task::deschedule(); }
s2.release();
let _ = p.recv();
});
Expand Down Expand Up @@ -848,7 +848,7 @@ mod tests {
c.send(());
});
let _ = p.recv(); // wait for child to come alive
5.times(|| { task::deschedule(); }); // let the child contend
for _ in range(0, 5) { task::deschedule(); } // let the child contend
});
let _ = p.recv(); // wait for child to be done
}
Expand Down Expand Up @@ -880,13 +880,13 @@ mod tests {
}

fn access_shared(sharedstate: &mut int, m: &Mutex, n: uint) {
n.times(|| {
for _ in range(0, n) {
m.lock(|| {
let oldval = *sharedstate;
task::deschedule();
*sharedstate = oldval + 1;
})
})
}
}
}
#[test]
Expand Down Expand Up @@ -926,7 +926,7 @@ mod tests {
let m = Mutex::new();
let mut ports = ~[];

num_waiters.times(|| {
for _ in range(0, num_waiters) {
let mi = m.clone();
let (port, chan) = Chan::new();
ports.push(port);
Expand All @@ -937,7 +937,7 @@ mod tests {
chan.send(());
})
});
});
}

// wait until all children get in the mutex
for port in ports.mut_iter() { let _ = port.recv(); }
Expand Down Expand Up @@ -1020,7 +1020,7 @@ mod tests {

let result: result::Result<(), ~Any> = task::try(proc() {
let mut sibling_convos = ~[];
2.times(|| {
for _ in range(0, 2) {
let (p, c) = Chan::new();
sibling_convos.push(p);
let mi = m2.clone();
Expand All @@ -1037,7 +1037,7 @@ mod tests {
})
})
});
});
}
for p in sibling_convos.mut_iter() {
let _ = p.recv(); // wait for sibling to get in the mutex
}
Expand Down Expand Up @@ -1156,13 +1156,13 @@ mod tests {

fn access_shared(sharedstate: &mut int, x: &RWLock, mode: RWLockMode,
n: uint) {
n.times(|| {
for _ in range(0, n) {
lock_rwlock_in_mode(x, mode, || {
let oldval = *sharedstate;
task::deschedule();
*sharedstate = oldval + 1;
})
})
}
}
}
#[test]
Expand Down Expand Up @@ -1287,7 +1287,7 @@ mod tests {
let x = RWLock::new();
let mut ports = ~[];

num_waiters.times(|| {
for _ in range(0, num_waiters) {
let xi = x.clone();
let (port, chan) = Chan::new();
ports.push(port);
Expand All @@ -1298,7 +1298,7 @@ mod tests {
chan.send(());
})
});
});
}

// wait until all children get in the mutex
for port in ports.mut_iter() { let _ = port.recv(); }
Expand Down Expand Up @@ -1388,14 +1388,14 @@ mod tests {
let barrier = Barrier::new(10);
let (port, chan) = SharedChan::new();

9.times(|| {
for _ in range(0, 9) {
let c = barrier.clone();
let chan = chan.clone();
spawn(proc() {
c.wait();
chan.send(true);
});
});
}

// At this point, all spawned tasks should be blocked,
// so we shouldn't get anything from the port
Expand All @@ -1406,8 +1406,8 @@ mod tests {

barrier.wait();
// Now, the barrier is cleared and we should get data.
9.times(|| {
for _ in range(0, 9) {
port.recv();
});
}
}
}
Loading