提交 ac6aba01 编写于 作者: N Niko Matsakis

rename iter2 to iteri to match typical convention

上级 2833ca47
......@@ -218,7 +218,7 @@ fn maybe_clone_tydesc(bcx: @block_ctxt,
let {bcx:bcx, val:ty_params_slot} =
GEP_tup_like_1(bcx, closure_ty, closure,
[0, abi::closure_elt_ty_params]);
vec::iter2(lltydescs) { |i, td|
vec::iteri(lltydescs) { |i, td|
let ty_param_slot = GEPi(bcx, ty_params_slot, [0, i as int]);
let cloned_td = maybe_clone_tydesc(bcx, ck, td);
Store(bcx, cloned_td, ty_param_slot);
......@@ -226,7 +226,7 @@ fn maybe_clone_tydesc(bcx: @block_ctxt,
// Copy expr values into boxed bindings.
// Silly check
vec::iter2(bound_values) { |i, bv|
vec::iteri(bound_values) { |i, bv|
let bound = trans::GEP_tup_like_1(bcx, box_ty, box,
[0, abi::box_rc_field_body,
abi::closure_elt_bindings,
......@@ -310,7 +310,7 @@ fn load_environment(enclosing_cx: @block_ctxt,
// Populate the upvars from the environment.
let path = [0, abi::box_rc_field_body, abi::closure_elt_bindings];
vec::iter2(*upvars) { |i, upvar_def|
vec::iteri(*upvars) { |i, upvar_def|
check type_is_tup_like(bcx, boxed_closure_ty);
let upvarptr =
GEP_tup_like(bcx, boxed_closure_ty, llclosure, path + [i as int]);
......
......@@ -697,18 +697,18 @@ fn enum_uints(start: uint, end: uint) : uint::le(start, end) -> [uint] {
*/
fn iter<T>(v: [const T], f: block(T)) {
iter2(v) { |_i, v| f(v) }
iteri(v) { |_i, v| f(v) }
}
/*
Function: iter2
Function: iteri
Iterates over a vector's elements and indexes
Iterates over vector `v` and, for each element, calls function `f` with the
element's value and index.
*/
fn iter2<T>(v: [const T], f: block(uint, T)) {
fn iteri<T>(v: [const T], f: block(uint, T)) {
let i = 0u, l = len(v);
while i < l { f(i, v[i]); i += 1u; }
}
......@@ -723,18 +723,18 @@ fn iter2<T>(v: [const T], f: block(uint, T)) {
*/
fn riter<T>(v: [const T], f: block(T)) {
riter2(v) { |_i, v| f(v) }
riteri(v) { |_i, v| f(v) }
}
/*
Function: riter2
Function: riteri
Iterates over a vector's elements and indexes in reverse
Iterates over vector `v` and, for each element, calls function `f` with the
element's value and index.
*/
fn riter2<T>(v: [const T], f: block(uint, T)) {
fn riteri<T>(v: [const T], f: block(uint, T)) {
let i = len(v);
while 0u < i {
i -= 1u;
......
......@@ -329,9 +329,9 @@ fn iter_nonempty() {
}
#[test]
fn iter2() {
fn iteri() {
let i = 0;
vec::iter2([1, 2, 3], { |j, v|
vec::iteri([1, 2, 3], { |j, v|
if i == 0 { assert v == 1; }
assert j + 1u == v as uint;
i += v;
......@@ -357,9 +357,9 @@ fn riter_nonempty() {
}
#[test]
fn riter2() {
fn riteri() {
let i = 0;
vec::riter2([0, 1, 2], { |j, v|
vec::riteri([0, 1, 2], { |j, v|
if i == 0 { assert v == 2; }
assert j == v as uint;
i += v;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册