Stop using the deprecated range function.

This commit is contained in:
Ms2ger 2015-04-22 19:51:17 +02:00
parent c4b7979450
commit 4d41f1c991
17 changed files with 27 additions and 28 deletions

View file

@ -1130,7 +1130,7 @@ impl DisplayItem {
pub fn debug_with_level(&self, level: u32) {
let mut indent = String::new();
for _ in range(0, level) {
for _ in 0..level {
indent.push_str("| ")
}
println!("{}+ {:?}", indent, self);

View file

@ -23,7 +23,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>
node: OpaqueNode,
old_style: &ComputedValues,
new_style: &mut ComputedValues) {
for i in range(0, new_style.get_animation().transition_property.0.len()) {
for i in 0..new_style.get_animation().transition_property.0.len() {
// Create any property animations, if applicable.
let property_animations = PropertyAnimation::from_transition(i, old_style, new_style);
for property_animation in property_animations.into_iter() {

View file

@ -1199,7 +1199,7 @@ impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) {
/// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level.
fn dump_with_level(self, level: u32) {
let mut indent = String::new();
for _ in range(0, level) {
for _ in 0..level {
indent.push_str("| ")
}

View file

@ -530,7 +530,7 @@ fn push_alphabetic_representation(mut value: i32, system: &[char], accumulator:
value = ((value as usize) / system.len()) as i32;
}
for i in range(0, string.len()).rev() {
for i in (0..string.len()).rev() {
accumulator.push(*string.get(i))
}
}

View file

@ -919,7 +919,7 @@ impl InlineFlow {
}
}
for fragment_index in range(line.range.begin(), line.range.end()) {
for fragment_index in line.range.begin()..line.range.end() {
let fragment = fragments.get_mut(fragment_index.to_usize());
let size = fragment.border_box.size;
fragment.border_box = LogicalRect::new(fragment.style.writing_mode,
@ -1008,7 +1008,7 @@ impl InlineFlow {
line_distance_from_flow_block_start: Au,
baseline_distance_from_block_start: Au,
largest_depth_below_baseline: Au) {
for fragment_index in range(line.range.begin(), line.range.end()) {
for fragment_index in line.range.begin()..line.range.end() {
// If any of the inline styles say `top` or `bottom`, adjust the vertical align
// appropriately.
//
@ -1224,7 +1224,7 @@ impl Flow for InlineFlow {
// Now, go through each line and lay out the fragments inside.
let mut line_distance_from_flow_block_start = Au(0);
let line_count = self.lines.len();
for line_index in range(0, line_count) {
for line_index in 0..line_count {
let line = &mut self.lines[line_index];
// Lay out fragments in the inline direction, and justify them if necessary.
@ -1248,7 +1248,7 @@ impl Flow for InlineFlow {
let (mut largest_block_size_for_top_fragments,
mut largest_block_size_for_bottom_fragments) = (Au(0), Au(0));
for fragment_index in range(line.range.begin(), line.range.end()) {
for fragment_index in line.range.begin()..line.range.end() {
let fragment = &mut self.fragments.fragments[fragment_index.to_usize()];
let InlineMetrics {

View file

@ -98,7 +98,7 @@ impl TableFlow {
let mut total_inline_sizes = IntrinsicISizes::new();
let mut column_index = 0;
for child_cell_inline_size in child_cell_inline_sizes.iter() {
for _ in range(0, child_cell_inline_size.column_span) {
for _ in 0..child_cell_inline_size.column_span {
if column_index < parent_inline_sizes.len() {
// We already have some intrinsic size information for this column. Merge it in
// according to the rules specified in INTRINSIC § 4.

View file

@ -73,7 +73,7 @@ impl Flow for TableColGroupFlow {
SpecificFragmentInfo::TableColumn(col_fragment) => max(col_fragment.span, 1),
_ => panic!("non-table-column fragment inside table column?!"),
};
for _ in range(0, span) {
for _ in 0..span {
self.inline_sizes.push(inline_size)
}
}

View file

@ -266,7 +266,7 @@ impl Flow for TableRowFlow {
};
// Add in computed inline sizes for any extra columns in the span.
for _ in range(1, cell_intrinsic_inline_size.column_span) {
for _ in 1..cell_intrinsic_inline_size.column_span {
let extra_column_computed_inline_size =
match column_computed_inline_size_iterator.next() {
Some(column_computed_inline_size) => column_computed_inline_size,

View file

@ -250,7 +250,7 @@ impl<'ln> LayoutNode<'ln> {
fn dump_indent(self, indent: u32) {
let mut s = String::new();
for _ in range(0, indent) {
for _ in 0..indent {
s.push_str(" ");
}

View file

@ -285,7 +285,7 @@ impl ReportsTree {
}
let mut indent_str = String::new();
for _ in range(0, depth) {
for _ in 0..depth {
indent_str.push_str(" ");
}

View file

@ -1049,7 +1049,7 @@ class CGArgumentConverter(CGThing):
variadicConversion = string.Template(
"let mut vector: ${seqType} = Vec::with_capacity((${argc} - ${index}) as usize);\n"
"for variadicArg in range(${index}, ${argc}) {\n"
"for variadicArg in ${index}..${argc} {\n"
"${inner}\n"
" vector.push(slot);\n"
"}\n"
@ -5157,7 +5157,7 @@ class CallbackMember(CGNativeMember):
successCode="")
if arg.variadic:
conversion = string.Template(
"for idx in range(0, ${arg}.len()) {\n" +
"for idx in 0..${arg}.len() {\n" +
CGIndenter(CGGeneric(conversion)).define() + "\n"
"}"
).substitute({ "arg": arg.identifier.name })

View file

@ -473,7 +473,7 @@ pub fn find_enum_string_index(cx: *mut JSContext,
Ok(values.iter().position(|value| {
value.len() == length as usize &&
range(0, length as usize).all(|j| {
(0..length as usize).all(|j| {
value.as_bytes()[j] as u16 == *chars.offset(j as isize)
})
}))

View file

@ -59,7 +59,7 @@ impl Bezier {
fn solve_curve_x(&self, x: f64, epsilon: f64) -> f64 {
// Fast path: Use Newton's method.
let mut t = x;
for _ in range(0, NEWTON_METHOD_ITERATIONS) {
for _ in 0..NEWTON_METHOD_ITERATIONS {
let x2 = self.sample_curve_x(t);
if x2.approx_eq(x, epsilon) {
return t

View file

@ -339,7 +339,7 @@ impl<T: Send + 'static> Drop for Deque<T> {
let a = self.array.load(SeqCst);
// Free whatever is leftover in the dequeue, and then move the buffer
// back into the pool.
for i in range(t, b) {
for i in t..b {
let _: T = unsafe { (*a).get(i) };
}
self.pool.free(unsafe { transmute(a) });
@ -392,7 +392,7 @@ impl<T: Send> Buffer<T> {
// casting delta to usize and then adding gives the desired
// effect.
let buf = Buffer::new(self.log_size.wrapping_add(delta as usize));
for i in range(t, b) {
for i in t..b {
buf.put(i, self.get(i));
}
return buf;

View file

@ -3,11 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::cmp::{max, min};
use std::iter;
use std::fmt;
use std::num;
use std::num::Int;
use std::marker::PhantomData;
use std::num::{self, Int};
use std::ops;
/// An index type to be used by a `Range`
pub trait RangeIndex: Int + fmt::Debug {
@ -239,12 +238,12 @@ impl<I: RangeIndex> fmt::Debug for Range<I> {
/// An iterator over each index in a range
pub struct EachIndex<T, I> {
it: iter::Range<T>,
it: ops::Range<T>,
phantom: PhantomData<I>,
}
pub fn each_index<T: Int, I: RangeIndex<Index=T>>(start: I, stop: I) -> EachIndex<T, I> {
EachIndex { it: iter::range(start.get(), stop.get()), phantom: PhantomData }
EachIndex { it: start.get()..stop.get(), phantom: PhantomData }
}
impl<T: Int, I: RangeIndex<Index=T>> Iterator for EachIndex<T, I> {

View file

@ -154,7 +154,7 @@ fn read_input_device(device_path: &Path,
let count = read / size_of::<linux_input_event>();
let events: *mut linux_input_event = unsafe { transmute(buf.as_mut_ptr()) };
let mut tracking_updated = false;
for idx in range(0, count as int) {
for idx in 0..(count as int) {
let event: &linux_input_event = unsafe { transmute(events.offset(idx)) };
match (event.evt_type, event.code) {
(EV_SYN, EV_REPORT) => {

View file

@ -341,7 +341,7 @@ extern fn query(base: *const ANativeWindow,
extern fn dequeueBuffer(base: *mut ANativeWindow, buf: *mut *mut ANativeWindowBuffer, fence: *mut c_int) -> c_int {
unsafe {
let window: &mut GonkNativeWindow = transmute(base);
for idx in range(0, window.bufs.len()) {
for idx in 0..window.bufs.len() {
if idx == window.last_idx as uint {
continue;
}
@ -363,7 +363,7 @@ extern fn dequeueBuffer(base: *mut ANativeWindow, buf: *mut *mut ANativeWindowBu
extern fn queueBuffer(base: *mut ANativeWindow, buf: *mut ANativeWindowBuffer, fence: c_int) -> c_int {
unsafe {
let window: &mut GonkNativeWindow = transmute(base);
for idx in range(0, window.bufs.len()) {
for idx in 0..window.bufs.len() {
match window.bufs[idx] {
Some(_) => (),
None => {
@ -381,7 +381,7 @@ extern fn queueBuffer(base: *mut ANativeWindow, buf: *mut ANativeWindowBuffer, f
extern fn cancelBuffer(base: *mut ANativeWindow, buf: *mut ANativeWindowBuffer, fence: c_int) -> c_int {
unsafe {
let window: &mut GonkNativeWindow = transmute(base);
for idx in range(0, window.bufs.len()) {
for idx in 0..window.bufs.len() {
match window.bufs[idx] {
Some(_) => (),
None => {