convert remaining `range(a, b)` to `a..b`

This commit is contained in:
Jorge Aparicio 2015-01-26 16:05:07 -05:00
parent 7d661af9c8
commit efc97a51ff
48 changed files with 101 additions and 102 deletions

View File

@ -67,7 +67,7 @@
//! // for a simpler implementation. //! // for a simpler implementation.
//! fn shortest_path(adj_list: &Vec<Vec<Edge>>, start: uint, goal: uint) -> uint { //! fn shortest_path(adj_list: &Vec<Vec<Edge>>, start: uint, goal: uint) -> uint {
//! // dist[node] = current shortest distance from `start` to `node` //! // dist[node] = current shortest distance from `start` to `node`
//! let mut dist: Vec<_> = range(0, adj_list.len()).map(|_| uint::MAX).collect(); //! let mut dist: Vec<_> = (0..adj_list.len()).map(|_| uint::MAX).collect();
//! //!
//! let mut heap = BinaryHeap::new(); //! let mut heap = BinaryHeap::new();
//! //!

View File

@ -1730,7 +1730,7 @@ mod test {
let map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect(); let map: BTreeMap<uint, uint> = (0..size).map(|i| (i, i)).collect();
let mut j = 0u; let mut j = 0u;
for ((&k, &v), i) in map.range(Included(&2), Unbounded).zip(range(2u, size)) { for ((&k, &v), i) in map.range(Included(&2), Unbounded).zip(2u..size) {
assert_eq!(k, i); assert_eq!(k, i);
assert_eq!(v, i); assert_eq!(v, i);
j += 1; j += 1;

View File

@ -599,7 +599,7 @@ impl<T> DList<T> {
} else { } else {
// better off starting from the end // better off starting from the end
let mut iter = self.iter_mut(); let mut iter = self.iter_mut();
for _ in range(0, len - 1 - (at - 1)) { for _ in 0..len - 1 - (at - 1) {
iter.next_back(); iter.next_back();
} }
iter.tail iter.tail

View File

@ -388,7 +388,7 @@ impl<T> RingBuf<T> {
/// use std::collections::RingBuf; /// use std::collections::RingBuf;
/// ///
/// let mut buf = RingBuf::with_capacity(15); /// let mut buf = RingBuf::with_capacity(15);
/// buf.extend(range(0u, 4)); /// buf.extend(0u..4);
/// assert_eq!(buf.capacity(), 15); /// assert_eq!(buf.capacity(), 15);
/// buf.shrink_to_fit(); /// buf.shrink_to_fit();
/// assert!(buf.capacity() >= 4); /// assert!(buf.capacity() >= 4);
@ -483,7 +483,7 @@ impl<T> RingBuf<T> {
#[unstable(feature = "collections", #[unstable(feature = "collections",
reason = "matches collection reform specification; waiting on panic semantics")] reason = "matches collection reform specification; waiting on panic semantics")]
pub fn truncate(&mut self, len: uint) { pub fn truncate(&mut self, len: uint) {
for _ in range(len, self.len()) { for _ in len..self.len() {
self.pop_back(); self.pop_back();
} }
} }

View File

@ -1254,7 +1254,7 @@ impl Iterator for ElementSwaps {
#[inline] #[inline]
fn size_hint(&self) -> (uint, Option<uint>) { fn size_hint(&self) -> (uint, Option<uint>) {
// For a vector of size n, there are exactly n! permutations. // For a vector of size n, there are exactly n! permutations.
let n = range(2, self.sdir.len() + 1).product(); let n = (2..self.sdir.len() + 1).product();
(n - self.swaps_made, Some(n - self.swaps_made)) (n - self.swaps_made, Some(n - self.swaps_made))
} }
} }
@ -1385,7 +1385,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
// .offset-ing. // .offset-ing.
for start in range_step(0, len, insertion) { for start in range_step(0, len, insertion) {
// start <= i < len; // start <= i < len;
for i in range(start, cmp::min(start + insertion, len)) { for i in start..cmp::min(start + insertion, len) {
// j satisfies: start <= j <= i; // j satisfies: start <= j <= i;
let mut j = i as int; let mut j = i as int;
unsafe { unsafe {

View File

@ -1079,7 +1079,7 @@ impl<T: Clone> Vec<T> {
pub fn push_all(&mut self, other: &[T]) { pub fn push_all(&mut self, other: &[T]) {
self.reserve(other.len()); self.reserve(other.len());
for i in range(0, other.len()) { for i in 0..other.len() {
let len = self.len(); let len = self.len();
// Unsafe code so this can be optimised to a memcpy (or something similarly // Unsafe code so this can be optimised to a memcpy (or something similarly
@ -1988,12 +1988,12 @@ mod tests {
let mut v = Vec::new(); let mut v = Vec::new();
let mut w = Vec::new(); let mut w = Vec::new();
v.extend(range(0i, 3)); v.extend(0i..3);
for i in 0i..3 { w.push(i) } for i in 0i..3 { w.push(i) }
assert_eq!(v, w); assert_eq!(v, w);
v.extend(range(3i, 10)); v.extend(3i..10);
for i in 3i..10 { w.push(i) } for i in 3i..10 { w.push(i) }
assert_eq!(v, w); assert_eq!(v, w);
@ -2499,7 +2499,7 @@ mod tests {
} }
fn do_bench_from_slice(b: &mut Bencher, src_len: uint) { fn do_bench_from_slice(b: &mut Bencher, src_len: uint) {
let src: Vec<uint> = FromIterator::from_iter(range(0, src_len)); let src: Vec<uint> = FromIterator::from_iter(0..src_len);
b.bytes = src_len as u64; b.bytes = src_len as u64;
@ -2531,7 +2531,7 @@ mod tests {
} }
fn do_bench_from_iter(b: &mut Bencher, src_len: uint) { fn do_bench_from_iter(b: &mut Bencher, src_len: uint) {
let src: Vec<uint> = FromIterator::from_iter(range(0, src_len)); let src: Vec<uint> = FromIterator::from_iter(0..src_len);
b.bytes = src_len as u64; b.bytes = src_len as u64;
@ -2563,8 +2563,8 @@ mod tests {
} }
fn do_bench_extend(b: &mut Bencher, dst_len: uint, src_len: uint) { fn do_bench_extend(b: &mut Bencher, dst_len: uint, src_len: uint) {
let dst: Vec<uint> = FromIterator::from_iter(range(0, dst_len)); let dst: Vec<uint> = FromIterator::from_iter(0..dst_len);
let src: Vec<uint> = FromIterator::from_iter(range(dst_len, dst_len + src_len)); let src: Vec<uint> = FromIterator::from_iter(dst_len..dst_len + src_len);
b.bytes = src_len as u64; b.bytes = src_len as u64;
@ -2612,8 +2612,8 @@ mod tests {
} }
fn do_bench_push_all(b: &mut Bencher, dst_len: uint, src_len: uint) { fn do_bench_push_all(b: &mut Bencher, dst_len: uint, src_len: uint) {
let dst: Vec<uint> = FromIterator::from_iter(range(0, dst_len)); let dst: Vec<uint> = FromIterator::from_iter(0..dst_len);
let src: Vec<uint> = FromIterator::from_iter(range(dst_len, dst_len + src_len)); let src: Vec<uint> = FromIterator::from_iter(dst_len..dst_len + src_len);
b.bytes = src_len as u64; b.bytes = src_len as u64;
@ -2661,8 +2661,8 @@ mod tests {
} }
fn do_bench_push_all_move(b: &mut Bencher, dst_len: uint, src_len: uint) { fn do_bench_push_all_move(b: &mut Bencher, dst_len: uint, src_len: uint) {
let dst: Vec<uint> = FromIterator::from_iter(range(0u, dst_len)); let dst: Vec<uint> = FromIterator::from_iter(0u..dst_len);
let src: Vec<uint> = FromIterator::from_iter(range(dst_len, dst_len + src_len)); let src: Vec<uint> = FromIterator::from_iter(dst_len..dst_len + src_len);
b.bytes = src_len as u64; b.bytes = src_len as u64;
@ -2710,7 +2710,7 @@ mod tests {
} }
fn do_bench_clone(b: &mut Bencher, src_len: uint) { fn do_bench_clone(b: &mut Bencher, src_len: uint) {
let src: Vec<uint> = FromIterator::from_iter(range(0, src_len)); let src: Vec<uint> = FromIterator::from_iter(0..src_len);
b.bytes = src_len as u64; b.bytes = src_len as u64;
@ -2742,8 +2742,8 @@ mod tests {
} }
fn do_bench_clone_from(b: &mut Bencher, times: uint, dst_len: uint, src_len: uint) { fn do_bench_clone_from(b: &mut Bencher, times: uint, dst_len: uint, src_len: uint) {
let dst: Vec<uint> = FromIterator::from_iter(range(0, src_len)); let dst: Vec<uint> = FromIterator::from_iter(0..src_len);
let src: Vec<uint> = FromIterator::from_iter(range(dst_len, dst_len + src_len)); let src: Vec<uint> = FromIterator::from_iter(dst_len..dst_len + src_len);
b.bytes = (times * src_len) as u64; b.bytes = (times * src_len) as u64;

View File

@ -459,7 +459,7 @@ impl<V> VecMap<V> {
pub fn insert(&mut self, key: uint, value: V) -> Option<V> { pub fn insert(&mut self, key: uint, value: V) -> Option<V> {
let len = self.v.len(); let len = self.v.len();
if len <= key { if len <= key {
self.v.extend(range(0, key - len + 1).map(|_| None)); self.v.extend((0..key - len + 1).map(|_| None));
} }
replace(&mut self.v[key], Some(value)) replace(&mut self.v[key], Some(value))
} }

View File

@ -125,7 +125,7 @@ impl<T> ToOwned<T> for T where T: Clone {
/// use std::borrow::Cow; /// use std::borrow::Cow;
/// ///
/// fn abs_all(input: &mut Cow<Vec<int>, [int]>) { /// fn abs_all(input: &mut Cow<Vec<int>, [int]>) {
/// for i in range(0, input.len()) { /// for i in 0..input.len() {
/// let v = input[i]; /// let v = input[i];
/// if v < 0 { /// if v < 0 {
/// // clones into a vector the first time (if not already owned) /// // clones into a vector the first time (if not already owned)

View File

@ -800,7 +800,7 @@ impl TwoWaySearcher {
// See if the right part of the needle matches // See if the right part of the needle matches
let start = if long_period { self.crit_pos } let start = if long_period { self.crit_pos }
else { cmp::max(self.crit_pos, self.memory) }; else { cmp::max(self.crit_pos, self.memory) };
for i in range(start, needle.len()) { for i in start..needle.len() {
if needle[i] != haystack[self.position + i] { if needle[i] != haystack[self.position + i] {
self.position += i - self.crit_pos + 1; self.position += i - self.crit_pos + 1;
if !long_period { if !long_period {

View File

@ -305,7 +305,7 @@ fn test_cycle() {
#[test] #[test]
fn test_iterator_nth() { fn test_iterator_nth() {
let v: &[_] = &[0i, 1, 2, 3, 4]; let v: &[_] = &[0i, 1, 2, 3, 4];
for i in range(0u, v.len()) { for i in 0u..v.len() {
assert_eq!(v.iter().nth(i).unwrap(), &v[i]); assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
} }
assert_eq!(v.iter().nth(v.len()), None); assert_eq!(v.iter().nth(v.len()), None);
@ -458,7 +458,7 @@ fn test_min_by() {
#[test] #[test]
fn test_by_ref() { fn test_by_ref() {
let mut xs = range(0i, 10); let mut xs = 0i..10;
// sum the first five values // sum the first five values
let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b); let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b);
assert_eq!(partial_sum, 10); assert_eq!(partial_sum, 10);
@ -730,12 +730,12 @@ fn test_random_access_cycle() {
#[test] #[test]
fn test_double_ended_range() { fn test_double_ended_range() {
assert!(range(11i, 14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]); assert!((11i..14).rev().collect::<Vec<int>>() == vec![13i, 12, 11]);
for _ in (10i..0).rev() { for _ in (10i..0).rev() {
panic!("unreachable"); panic!("unreachable");
} }
assert!(range(11u, 14).rev().collect::<Vec<uint>>() == vec![13u, 12, 11]); assert!((11u..14).rev().collect::<Vec<uint>>() == vec![13u, 12, 11]);
for _ in (10u..0).rev() { for _ in (10u..0).rev() {
panic!("unreachable"); panic!("unreachable");
} }
@ -743,19 +743,19 @@ fn test_double_ended_range() {
#[test] #[test]
fn test_range() { fn test_range() {
assert!(range(0i, 5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]); assert!((0i..5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]);
assert!(range(-10i, -1).collect::<Vec<int>>() == assert!((-10i..-1).collect::<Vec<int>>() ==
vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]); vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]);
assert!(range(0i, 5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]); assert!((0i..5).rev().collect::<Vec<int>>() == vec![4, 3, 2, 1, 0]);
assert_eq!(range(200i, -5).count(), 0); assert_eq!((200i..-5).count(), 0);
assert_eq!(range(200i, -5).rev().count(), 0); assert_eq!((200i..-5).rev().count(), 0);
assert_eq!(range(200i, 200).count(), 0); assert_eq!((200i..200).count(), 0);
assert_eq!(range(200i, 200).rev().count(), 0); assert_eq!((200i..200).rev().count(), 0);
assert_eq!(range(0i, 100).size_hint(), (100, Some(100))); assert_eq!((0i..100).size_hint(), (100, Some(100)));
// this test is only meaningful when sizeof uint < sizeof u64 // this test is only meaningful when sizeof uint < sizeof u64
assert_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1))); assert_eq!((uint::MAX - 1..uint::MAX).size_hint(), (1, Some(1)));
assert_eq!(range(-10i, -1).size_hint(), (9, Some(9))); assert_eq!((-10i..-1).size_hint(), (9, Some(9)));
} }
#[test] #[test]
@ -892,7 +892,7 @@ fn bench_rposition(b: &mut Bencher) {
#[bench] #[bench]
fn bench_skip_while(b: &mut Bencher) { fn bench_skip_while(b: &mut Bencher) {
b.iter(|| { b.iter(|| {
let it = range(0u, 100); let it = 0u..100;
let mut sum = 0; let mut sum = 0;
it.skip_while(|&x| { sum += x; sum < 4000 }).all(|_| true); it.skip_while(|&x| { sum += x; sum < 4000 }).all(|_| true);
}); });

View File

@ -17,7 +17,7 @@ fn test_bool_from_str() {
fn check_contains_all_substrings(s: &str) { fn check_contains_all_substrings(s: &str) {
assert!(s.contains("")); assert!(s.contains(""));
for i in range(0, s.len()) { for i in 0..s.len() {
for j in range(i+1, s.len() + 1) { for j in range(i+1, s.len() + 1) {
assert!(s.contains(&s[i..j])); assert!(s.contains(&s[i..j]));
} }

View File

@ -176,7 +176,7 @@
//! } //! }
//! //!
//! impl<'a> dot::GraphWalk<'a, Nd, Ed<'a>> for Graph { //! impl<'a> dot::GraphWalk<'a, Nd, Ed<'a>> for Graph {
//! fn nodes(&self) -> dot::Nodes<'a,Nd> { range(0,self.nodes.len()).collect() } //! fn nodes(&self) -> dot::Nodes<'a,Nd> { (0..self.nodes.len()).collect() }
//! fn edges(&'a self) -> dot::Edges<'a,Ed<'a>> { self.edges.iter().collect() } //! fn edges(&'a self) -> dot::Edges<'a,Ed<'a>> { self.edges.iter().collect() }
//! fn source(&self, e: &Ed) -> Nd { let & &(s,_) = e; s } //! fn source(&self, e: &Ed) -> Nd { let & &(s,_) = e; s }
//! fn target(&self, e: &Ed) -> Nd { let & &(_,t) = e; t } //! fn target(&self, e: &Ed) -> Nd { let & &(_,t) = e; t }
@ -715,7 +715,7 @@ mod tests {
impl<'a> GraphWalk<'a, Node, &'a Edge> for LabelledGraph { impl<'a> GraphWalk<'a, Node, &'a Edge> for LabelledGraph {
fn nodes(&'a self) -> Nodes<'a,Node> { fn nodes(&'a self) -> Nodes<'a,Node> {
range(0u, self.node_labels.len()).collect() (0u..self.node_labels.len()).collect()
} }
fn edges(&'a self) -> Edges<'a,&'a Edge> { fn edges(&'a self) -> Edges<'a,&'a Edge> {
self.edges.iter().collect() self.edges.iter().collect()

View File

@ -132,7 +132,7 @@ pub fn parse_state_from_data<'a, 'tcx>(data: &'a [u8], crate_num: ast::CrateNum,
fn data_log_string(data: &[u8], pos: uint) -> String { fn data_log_string(data: &[u8], pos: uint) -> String {
let mut buf = String::new(); let mut buf = String::new();
buf.push_str("<<"); buf.push_str("<<");
for i in range(pos, data.len()) { for i in pos..data.len() {
let c = data[i]; let c = data[i];
if c > 0x20 && c <= 0x7F { if c > 0x20 && c <= 0x7F {
buf.push(c as char); buf.push(c as char);

View File

@ -157,7 +157,7 @@ fn calculate_type(sess: &session::Session,
}); });
// Collect what we've got so far in the return vector. // Collect what we've got so far in the return vector.
let mut ret = range(1, sess.cstore.next_crate_num()).map(|i| { let mut ret = (1..sess.cstore.next_crate_num()).map(|i| {
match formats.get(&i).map(|v| *v) { match formats.get(&i).map(|v| *v) {
v @ Some(cstore::RequireDynamic) => v, v @ Some(cstore::RequireDynamic) => v,
_ => None, _ => None,

View File

@ -1229,8 +1229,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
let mut insert = Vec::new(); let mut insert = Vec::new();
if lifetimes.len() == 0 { if lifetimes.len() == 0 {
let anon = self.cur_anon.get(); let anon = self.cur_anon.get();
for (i, a) in range(anon, for (i, a) in (anon..anon+expected).enumerate() {
anon+expected).enumerate() {
if anon_nums.contains(&a) { if anon_nums.contains(&a) {
insert.push(i as u32); insert.push(i as u32);
} }

View File

@ -983,7 +983,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
} }
fn construct_var_data(&self) -> Vec<VarData> { fn construct_var_data(&self) -> Vec<VarData> {
range(0, self.num_vars() as uint).map(|_| { (0..self.num_vars() as uint).map(|_| {
VarData { VarData {
// All nodes are initially classified as contracting; during // All nodes are initially classified as contracting; during
// the expansion phase, we will shift the classification for // the expansion phase, we will shift the classification for
@ -1259,7 +1259,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
let mut opt_graph = None; let mut opt_graph = None;
for idx in range(0u, self.num_vars() as uint) { for idx in 0u..self.num_vars() as uint {
match var_data[idx].value { match var_data[idx].value {
Value(_) => { Value(_) => {
/* Inference successful */ /* Inference successful */
@ -1316,7 +1316,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
} }
} }
range(0, self.num_vars() as uint).map(|idx| var_data[idx].value).collect() (0..self.num_vars() as uint).map(|idx| var_data[idx].value).collect()
} }
fn construct_graph(&self) -> RegionGraph { fn construct_graph(&self) -> RegionGraph {

View File

@ -404,7 +404,7 @@ impl<'a> LifetimeContext<'a> {
} }
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) { fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) {
for i in range(0, lifetimes.len()) { for i in 0..lifetimes.len() {
let lifetime_i = &lifetimes[i]; let lifetime_i = &lifetimes[i];
let special_idents = [special_idents::static_lifetime]; let special_idents = [special_idents::static_lifetime];
@ -417,7 +417,7 @@ impl<'a> LifetimeContext<'a> {
} }
// It is a hard error to shadow a lifetime within the same scope. // It is a hard error to shadow a lifetime within the same scope.
for j in range(i + 1, lifetimes.len()) { for j in i + 1..lifetimes.len() {
let lifetime_j = &lifetimes[j]; let lifetime_j = &lifetimes[j];
if lifetime_i.lifetime.name == lifetime_j.lifetime.name { if lifetime_i.lifetime.name == lifetime_j.lifetime.name {

View File

@ -595,7 +595,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let mut i = 0; let mut i = 0;
while i < candidates.len() { while i < candidates.len() {
let is_dup = let is_dup =
range(0, candidates.len()) (0..candidates.len())
.filter(|&j| i != j) .filter(|&j| i != j)
.any(|j| self.candidate_should_be_dropped_in_favor_of(stack, .any(|j| self.candidate_should_be_dropped_in_favor_of(stack,
&candidates[i], &candidates[i],

View File

@ -14,7 +14,7 @@ pub fn lev_distance(me: &str, t: &str) -> uint {
if me.is_empty() { return t.chars().count(); } if me.is_empty() { return t.chars().count(); }
if t.is_empty() { return me.chars().count(); } if t.is_empty() { return me.chars().count(); }
let mut dcol: Vec<_> = range(0, t.len() + 1).collect(); let mut dcol: Vec<_> = (0..t.len() + 1).collect();
let mut t_last = 0; let mut t_last = 0;
for (i, sc) in me.chars().enumerate() { for (i, sc) in me.chars().enumerate() {

View File

@ -714,7 +714,7 @@ pub fn run_passes(sess: &Session,
cmd.args(&sess.target.target.options.pre_link_args[]); cmd.args(&sess.target.target.options.pre_link_args[]);
cmd.arg("-nostdlib"); cmd.arg("-nostdlib");
for index in range(0, trans.modules.len()) { for index in 0..trans.modules.len() {
cmd.arg(crate_output.with_extension(&format!("{}.o", index)[])); cmd.arg(crate_output.with_extension(&format!("{}.o", index)[]));
} }
@ -824,7 +824,7 @@ pub fn run_passes(sess: &Session,
let keep_numbered_bitcode = needs_crate_bitcode || let keep_numbered_bitcode = needs_crate_bitcode ||
(user_wants_bitcode && sess.opts.cg.codegen_units > 1); (user_wants_bitcode && sess.opts.cg.codegen_units > 1);
for i in range(0, trans.modules.len()) { for i in 0..trans.modules.len() {
if modules_config.emit_obj { if modules_config.emit_obj {
let ext = format!("{}.o", i); let ext = format!("{}.o", i);
remove(sess, &crate_output.with_extension(&ext[])); remove(sess, &crate_output.with_extension(&ext[]));

View File

@ -606,7 +606,7 @@ fn extract_variant_args<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
val: ValueRef) val: ValueRef)
-> ExtractedBlock<'blk, 'tcx> { -> ExtractedBlock<'blk, 'tcx> {
let _icx = push_ctxt("match::extract_variant_args"); let _icx = push_ctxt("match::extract_variant_args");
let args = range(0, adt::num_args(repr, disr_val)).map(|i| { let args = (0..adt::num_args(repr, disr_val)).map(|i| {
adt::trans_field_ptr(bcx, repr, val, disr_val, i) adt::trans_field_ptr(bcx, repr, val, disr_val, i)
}).collect(); }).collect();
@ -653,8 +653,8 @@ fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let vec_datum = match_datum(val, left_ty); let vec_datum = match_datum(val, left_ty);
let (base, len) = vec_datum.get_vec_base_and_len(bcx); let (base, len) = vec_datum.get_vec_base_and_len(bcx);
let mut elems = vec![]; let mut elems = vec![];
elems.extend(range(0, before).map(|i| GEPi(bcx, base, &[i]))); elems.extend((0..before).map(|i| GEPi(bcx, base, &[i])));
elems.extend(range(0, after).rev().map(|i| { elems.extend((0..after).rev().map(|i| {
InBoundsGEP(bcx, base, &[ InBoundsGEP(bcx, base, &[
Sub(bcx, len, C_uint(bcx.ccx(), i + 1), DebugLoc::None) Sub(bcx, len, C_uint(bcx.ccx(), i + 1), DebugLoc::None)
]) ])
@ -768,7 +768,7 @@ fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<uint> {
}) })
}; };
range(0, m[0].pats.len()) (0..m[0].pats.len())
.filter(column_contains_any_nonwild_patterns) .filter(column_contains_any_nonwild_patterns)
.map(|col| (col, column_score(m, col))) .map(|col| (col, column_score(m, col)))
.max_by(|&(_, score)| score) .max_by(|&(_, score)| score)
@ -1005,7 +1005,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let adt_vals = if any_irrefutable_adt_pat(bcx.tcx(), m, col) { let adt_vals = if any_irrefutable_adt_pat(bcx.tcx(), m, col) {
let repr = adt::represent_type(bcx.ccx(), left_ty); let repr = adt::represent_type(bcx.ccx(), left_ty);
let arg_count = adt::num_args(&*repr, 0); let arg_count = adt::num_args(&*repr, 0);
let field_vals: Vec<ValueRef> = std::iter::range(0, arg_count).map(|ix| let field_vals: Vec<ValueRef> = (0..arg_count).map(|ix|
adt::trans_field_ptr(bcx, &*repr, val, 0, ix) adt::trans_field_ptr(bcx, &*repr, val, 0, ix)
).collect(); ).collect();
Some(field_vals) Some(field_vals)

View File

@ -1651,7 +1651,7 @@ fn copy_closure_args_to_allocas<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
wasn't a tuple?!") wasn't a tuple?!")
} }
}; };
for j in range(0, args.len()) { for j in 0..args.len() {
let tuple_element_type = untupled_arg_types[j]; let tuple_element_type = untupled_arg_types[j];
let tuple_element_datum = let tuple_element_datum =
tuple_datum.get_element(bcx, tuple_datum.get_element(bcx,

View File

@ -905,7 +905,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
tuple_expr.id)); tuple_expr.id));
let repr = adt::represent_type(bcx.ccx(), tuple_type); let repr = adt::represent_type(bcx.ccx(), tuple_type);
let repr_ptr = &*repr; let repr_ptr = &*repr;
for i in range(0, field_types.len()) { for i in 0..field_types.len() {
let arg_datum = tuple_lvalue_datum.get_element( let arg_datum = tuple_lvalue_datum.get_element(
bcx, bcx,
field_types[i], field_types[i],

View File

@ -310,7 +310,7 @@ impl<'tcx> SharedCrateContext<'tcx> {
let (local_ccx, index) = let (local_ccx, index) =
self.local_ccxs self.local_ccxs
.iter() .iter()
.zip(range(0, self.local_ccxs.len())) .zip(0..self.local_ccxs.len())
.min_by(|&(local_ccx, _idx)| local_ccx.n_llvm_insns.get()) .min_by(|&(local_ccx, _idx)| local_ccx.n_llvm_insns.get())
.unwrap(); .unwrap();
CrateContext { CrateContext {

View File

@ -716,7 +716,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// Build up the arguments to the call to the rust function. // Build up the arguments to the call to the rust function.
// Careful to adapt for cases where the native convention uses // Careful to adapt for cases where the native convention uses
// a pointer and Rust does not or vice versa. // a pointer and Rust does not or vice versa.
for i in range(0, tys.fn_sig.inputs.len()) { for i in 0..tys.fn_sig.inputs.len() {
let rust_ty = tys.fn_sig.inputs[i]; let rust_ty = tys.fn_sig.inputs[i];
let llrust_ty = tys.llsig.llarg_tys[i]; let llrust_ty = tys.llsig.llarg_tys[i];
let rust_indirect = type_of::arg_is_indirect(ccx, rust_ty); let rust_indirect = type_of::arg_is_indirect(ccx, rust_ty);

View File

@ -314,7 +314,7 @@ fn create_substs_for_ast_path<'tcx>(
match anon_regions { match anon_regions {
Ok(v) => v.into_iter().collect(), Ok(v) => v.into_iter().collect(),
Err(_) => range(0, expected_num_region_params) Err(_) => (0..expected_num_region_params)
.map(|_| ty::ReStatic).collect() // hokey .map(|_| ty::ReStatic).collect() // hokey
} }
}; };

View File

@ -167,7 +167,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
} }
ast::PatTup(ref elements) => { ast::PatTup(ref elements) => {
let element_tys: Vec<_> = let element_tys: Vec<_> =
range(0, elements.len()).map(|_| fcx.infcx().next_ty_var()) (0..elements.len()).map(|_| fcx.infcx().next_ty_var())
.collect(); .collect();
let pat_ty = ty::mk_tup(tcx, element_tys.clone()); let pat_ty = ty::mk_tup(tcx, element_tys.clone());
fcx.write_ty(pat.id, pat_ty); fcx.write_ty(pat.id, pat_ty);

View File

@ -1871,7 +1871,7 @@ impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> {
fn anon_regions(&self, span: Span, count: uint) fn anon_regions(&self, span: Span, count: uint)
-> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> { -> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> {
Ok(range(0, count).map(|_| { Ok((0..count).map(|_| {
self.infcx().next_region_var(infer::MiscVariable(span)) self.infcx().next_region_var(infer::MiscVariable(span))
}).collect()) }).collect())
} }
@ -1903,7 +1903,7 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
lvalue_pref); lvalue_pref);
let mut t = base_ty; let mut t = base_ty;
for autoderefs in range(0, fcx.tcx().sess.recursion_limit.get()) { for autoderefs in 0..fcx.tcx().sess.recursion_limit.get() {
let resolved_t = structurally_resolved_type(fcx, sp, t); let resolved_t = structurally_resolved_type(fcx, sp, t);
if ty::type_is_error(resolved_t) { if ty::type_is_error(resolved_t) {
@ -5107,7 +5107,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// that the *default* type are expressed in terms of all prior // that the *default* type are expressed in terms of all prior
// parameters, so we have to substitute as we go with the // parameters, so we have to substitute as we go with the
// partial substitution that we have built up. // partial substitution that we have built up.
for i in range(provided_len, desired.len()) { for i in provided_len..desired.len() {
let default = desired[i].default.unwrap(); let default = desired[i].default.unwrap();
let default = default.subst_spanned(fcx.tcx(), substs, Some(span)); let default = default.subst_spanned(fcx.tcx(), substs, Some(span));
substs.types.push(space, default); substs.types.push(space, default);

View File

@ -135,7 +135,7 @@ impl RegionScope for BindingRscope {
count: uint) count: uint)
-> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> -> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>>
{ {
Ok(range(0, count).map(|_| self.next_region()).collect()) Ok((0..count).map(|_| self.next_region()).collect())
} }
} }

View File

@ -1500,7 +1500,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
item: &clean::Item, items: &[clean::Item]) -> fmt::Result { item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
try!(document(w, item)); try!(document(w, item));
let mut indices = range(0, items.len()).filter(|i| { let mut indices = (0..items.len()).filter(|i| {
!cx.ignore_private_item(&items[*i]) !cx.ignore_private_item(&items[*i])
}).collect::<Vec<uint>>(); }).collect::<Vec<uint>>();

View File

@ -1326,7 +1326,7 @@ impl Stack {
/// Compares this stack with an array of StackElements. /// Compares this stack with an array of StackElements.
pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool { pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool {
if self.stack.len() != rhs.len() { return false; } if self.stack.len() != rhs.len() { return false; }
for i in range(0, rhs.len()) { for i in 0..rhs.len() {
if self.get(i) != rhs[i] { return false; } if self.get(i) != rhs[i] { return false; }
} }
return true; return true;
@ -1336,7 +1336,7 @@ impl Stack {
/// the ones passed as parameter. /// the ones passed as parameter.
pub fn starts_with(&self, rhs: &[StackElement]) -> bool { pub fn starts_with(&self, rhs: &[StackElement]) -> bool {
if self.stack.len() < rhs.len() { return false; } if self.stack.len() < rhs.len() { return false; }
for i in range(0, rhs.len()) { for i in 0..rhs.len() {
if self.get(i) != rhs[i] { return false; } if self.get(i) != rhs[i] { return false; }
} }
return true; return true;
@ -1347,7 +1347,7 @@ impl Stack {
pub fn ends_with(&self, rhs: &[StackElement]) -> bool { pub fn ends_with(&self, rhs: &[StackElement]) -> bool {
if self.stack.len() < rhs.len() { return false; } if self.stack.len() < rhs.len() { return false; }
let offset = self.stack.len() - rhs.len(); let offset = self.stack.len() - rhs.len();
for i in range(0, rhs.len()) { for i in 0..rhs.len() {
if self.get(i + offset) != rhs[i] { return false; } if self.get(i + offset) != rhs[i] { return false; }
} }
return true; return true;

View File

@ -1217,7 +1217,7 @@ mod test_set {
for _ in s.iter() { panic!("s should be empty!"); } for _ in s.iter() { panic!("s should be empty!"); }
// reset to try again. // reset to try again.
s.extend(range(1, 100)); s.extend(1..100);
} }
} }
} }

View File

@ -418,7 +418,7 @@ mod test {
#[test] #[test]
fn test_iter_reader() { fn test_iter_reader() {
let mut r = IterReader::new(range(0u8, 8)); let mut r = IterReader::new(0u8..8);
let mut buf = [0, 0, 0]; let mut buf = [0, 0, 0];
let len = r.read(&mut buf).unwrap(); let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3); assert_eq!(len, 3);
@ -437,7 +437,7 @@ mod test {
#[test] #[test]
fn iter_reader_zero_length() { fn iter_reader_zero_length() {
let mut r = IterReader::new(range(0u8, 8)); let mut r = IterReader::new(0u8..8);
let mut buf = []; let mut buf = [];
assert_eq!(Ok(0), r.read(&mut buf)); assert_eq!(Ok(0), r.read(&mut buf));
} }

View File

@ -427,7 +427,7 @@ pub fn random<T: Rand>() -> T {
/// use std::rand::{thread_rng, sample}; /// use std::rand::{thread_rng, sample};
/// ///
/// let mut rng = thread_rng(); /// let mut rng = thread_rng();
/// let sample = sample(&mut rng, range(1i, 100), 5); /// let sample = sample(&mut rng, 1i..100, 5);
/// println!("{:?}", sample); /// println!("{:?}", sample);
/// ``` /// ```
pub fn sample<T, I: Iterator<Item=T>, R: Rng>(rng: &mut R, pub fn sample<T, I: Iterator<Item=T>, R: Rng>(rng: &mut R,

View File

@ -1346,7 +1346,7 @@ mod test {
#[test] #[test]
fn oneshot_multi_thread_close_stress() { fn oneshot_multi_thread_close_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = channel::<int>(); let (tx, rx) = channel::<int>();
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
drop(rx); drop(rx);
@ -1357,7 +1357,7 @@ mod test {
#[test] #[test]
fn oneshot_multi_thread_send_close_stress() { fn oneshot_multi_thread_send_close_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = channel::<int>(); let (tx, rx) = channel::<int>();
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
drop(rx); drop(rx);
@ -1370,7 +1370,7 @@ mod test {
#[test] #[test]
fn oneshot_multi_thread_recv_close_stress() { fn oneshot_multi_thread_recv_close_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = channel::<int>(); let (tx, rx) = channel::<int>();
Thread::spawn(move|| { Thread::spawn(move|| {
let res = Thread::scoped(move|| { let res = Thread::scoped(move|| {
@ -1388,7 +1388,7 @@ mod test {
#[test] #[test]
fn oneshot_multi_thread_send_recv_stress() { fn oneshot_multi_thread_send_recv_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
tx.send(box 10i).unwrap(); tx.send(box 10i).unwrap();
@ -1399,7 +1399,7 @@ mod test {
#[test] #[test]
fn stream_send_recv_stress() { fn stream_send_recv_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = channel(); let (tx, rx) = channel();
send(tx, 0); send(tx, 0);
@ -1810,7 +1810,7 @@ mod sync_tests {
#[test] #[test]
fn oneshot_multi_thread_close_stress() { fn oneshot_multi_thread_close_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = sync_channel::<int>(0); let (tx, rx) = sync_channel::<int>(0);
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
drop(rx); drop(rx);
@ -1821,7 +1821,7 @@ mod sync_tests {
#[test] #[test]
fn oneshot_multi_thread_send_close_stress() { fn oneshot_multi_thread_send_close_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = sync_channel::<int>(0); let (tx, rx) = sync_channel::<int>(0);
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
drop(rx); drop(rx);
@ -1834,7 +1834,7 @@ mod sync_tests {
#[test] #[test]
fn oneshot_multi_thread_recv_close_stress() { fn oneshot_multi_thread_recv_close_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = sync_channel::<int>(0); let (tx, rx) = sync_channel::<int>(0);
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
let res = Thread::scoped(move|| { let res = Thread::scoped(move|| {
@ -1852,7 +1852,7 @@ mod sync_tests {
#[test] #[test]
fn oneshot_multi_thread_send_recv_stress() { fn oneshot_multi_thread_send_recv_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = sync_channel::<Box<int>>(0); let (tx, rx) = sync_channel::<Box<int>>(0);
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
tx.send(box 10i).unwrap(); tx.send(box 10i).unwrap();
@ -1863,7 +1863,7 @@ mod sync_tests {
#[test] #[test]
fn stream_send_recv_stress() { fn stream_send_recv_stress() {
for _ in range(0, stress_factor()) { for _ in 0..stress_factor() {
let (tx, rx) = sync_channel::<Box<int>>(0); let (tx, rx) = sync_channel::<Box<int>>(0);
send(tx, 0); send(tx, 0);

View File

@ -224,7 +224,7 @@ impl Process {
if !setup(err_fd, libc::STDERR_FILENO) { fail(&mut output) } if !setup(err_fd, libc::STDERR_FILENO) { fail(&mut output) }
// close all other fds // close all other fds
for fd in range(3, getdtablesize()).rev() { for fd in (3..getdtablesize()).rev() {
if fd != output.fd() { if fd != output.fd() {
let _ = close(fd as c_int); let _ = close(fd as c_int);
} }

View File

@ -388,7 +388,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
cmd.push('"'); cmd.push('"');
} }
let argvec: Vec<char> = arg.chars().collect(); let argvec: Vec<char> = arg.chars().collect();
for i in range(0u, argvec.len()) { for i in 0u..argvec.len() {
append_char_at(cmd, argvec.as_slice(), i); append_char_at(cmd, argvec.as_slice(), i);
} }
if quote { if quote {

View File

@ -770,7 +770,7 @@ impl<'a> MethodDef<'a> {
let mut raw_fields = Vec::new(); // ~[[fields of self], let mut raw_fields = Vec::new(); // ~[[fields of self],
// [fields of next Self arg], [etc]] // [fields of next Self arg], [etc]]
let mut patterns = Vec::new(); let mut patterns = Vec::new();
for i in range(0us, self_args.len()) { for i in 0us..self_args.len() {
let struct_path= cx.path(DUMMY_SP, vec!( type_ident )); let struct_path= cx.path(DUMMY_SP, vec!( type_ident ));
let (pat, ident_expr) = let (pat, ident_expr) =
trait_.create_struct_pattern(cx, trait_.create_struct_pattern(cx,

View File

@ -661,7 +661,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span,
name_ordering: Vec<String>, name_ordering: Vec<String>,
names: HashMap<String, P<ast::Expr>>) names: HashMap<String, P<ast::Expr>>)
-> P<ast::Expr> { -> P<ast::Expr> {
let arg_types: Vec<_> = range(0, args.len()).map(|_| None).collect(); let arg_types: Vec<_> = (0..args.len()).map(|_| None).collect();
let mut cx = Context { let mut cx = Context {
ecx: ecx, ecx: ecx,
args: args, args: args,

View File

@ -665,7 +665,7 @@ fn mk_tt(cx: &ExtCtxt, tt: &ast::TokenTree) -> Vec<P<ast::Stmt>> {
} }
ref tt @ ast::TtToken(_, MatchNt(..)) => { ref tt @ ast::TtToken(_, MatchNt(..)) => {
let mut seq = vec![]; let mut seq = vec![];
for i in range(0, tt.len()) { for i in 0..tt.len() {
seq.push(tt.get_tt(i)); seq.push(tt.get_tt(i));
} }
mk_tts(cx, &seq[]) mk_tts(cx, &seq[])

View File

@ -392,7 +392,7 @@ pub fn parse(sess: &ParseSess,
cur_eis.push(new_ei); cur_eis.push(new_ei);
} }
let matches: Vec<_> = range(0, ei.matches.len()) let matches: Vec<_> = (0..ei.matches.len())
.map(|_| Vec::new()).collect(); .map(|_| Vec::new()).collect();
let ei_t = ei; let ei_t = ei;
cur_eis.push(box MatcherPos { cur_eis.push(box MatcherPos {

View File

@ -172,7 +172,7 @@ impl<T: Float + FromPrimitive> Stats<T> for [T] {
let mut j = 0; let mut j = 0;
// This inner loop applies `hi`/`lo` summation to each // This inner loop applies `hi`/`lo` summation to each
// partial so that the list of partial sums remains exact. // partial so that the list of partial sums remains exact.
for i in range(0, partials.len()) { for i in 0..partials.len() {
let mut y: T = partials[i]; let mut y: T = partials[i];
if x.abs() < y.abs() { if x.abs() < y.abs() {
mem::swap(&mut x, &mut y); mem::swap(&mut x, &mut y);

View File

@ -49,7 +49,7 @@ fn rotate(x: &mut [i32]) {
} }
fn next_permutation(perm: &mut [i32], count: &mut [i32]) { fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
for i in range(1, perm.len()) { for i in 1..perm.len() {
rotate(&mut perm[..i + 1]); rotate(&mut perm[..i + 1]);
let count_i = &mut count[i]; let count_i = &mut count[i];
if *count_i >= i as i32 { if *count_i >= i as i32 {

View File

@ -158,7 +158,7 @@ fn main() {
// initialize each sequence sorter // initialize each sequence sorter
let sizes = vec!(1u,2,3,4,6,12,18); let sizes = vec!(1u,2,3,4,6,12,18);
let mut streams = range(0, sizes.len()).map(|_| { let mut streams = (0..sizes.len()).map(|_| {
Some(channel::<String>()) Some(channel::<String>())
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
let mut from_child = Vec::new(); let mut from_child = Vec::new();

View File

@ -199,8 +199,8 @@ fn is_board_unfeasible(board: u64, masks: &Vec<Vec<Vec<u64>>>) -> bool {
// Filter the masks that we can prove to result to unfeasible board. // Filter the masks that we can prove to result to unfeasible board.
fn filter_masks(masks: &mut Vec<Vec<Vec<u64>>>) { fn filter_masks(masks: &mut Vec<Vec<Vec<u64>>>) {
for i in range(0, masks.len()) { for i in 0..masks.len() {
for j in range(0, (*masks)[i].len()) { for j in 0..(*masks)[i].len() {
masks[i][j] = masks[i][j] =
(*masks)[i][j].iter().map(|&m| m) (*masks)[i][j].iter().map(|&m| m)
.filter(|&m| !is_board_unfeasible(m, masks)) .filter(|&m| !is_board_unfeasible(m, masks))

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
range(0, 4) (0..4)
.map(|x| x * 2) .map(|x| x * 2)
.collect::<Vec<'a, usize, 'b>>() .collect::<Vec<'a, usize, 'b>>()
//~^ ERROR lifetime parameters must be declared prior to type parameters //~^ ERROR lifetime parameters must be declared prior to type parameters

View File

@ -29,7 +29,7 @@ fn foo(name: String, samples_chan: Sender<Msg>) {
// `box() (...)` syntax is needed to make pretty printer converge in one try: // `box() (...)` syntax is needed to make pretty printer converge in one try:
let callback: SamplesFn = box() (move |buffer| { let callback: SamplesFn = box() (move |buffer| {
for i in range(0u, buffer.len()) { for i in 0u..buffer.len() {
println!("{}: {}", i, buffer[i]) println!("{}: {}", i, buffer[i])
} }
}); });

View File

@ -37,7 +37,7 @@ pub fn main() {
box BarStruct{ x: 2 } as Box<FooTrait> box BarStruct{ x: 2 } as Box<FooTrait>
); );
for i in range(0u, foos.len()) { for i in 0u..foos.len() {
assert_eq!(i, foos[i].foo()); assert_eq!(i, foos[i].foo());
} }
} }