Skip to content

Commit c7c2c28

Browse files
committed
---
yaml --- r: 140776 b: refs/heads/try2 c: 3aa1122 h: refs/heads/master v: v3
1 parent bed1537 commit c7c2c28

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e1a199227635deddbdf010b3a79c2c96112909d7
8+
refs/heads/try2: 3aa1122ec25d15a2a73a295f8298ad9c38b09a10
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/vec.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,8 +1681,8 @@ pub fn eachi_reverse<'r,T>(v: &'r [T],
16811681
*/
16821682
#[inline]
16831683
pub fn _each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool {
1684-
assert!(len(v1) == len(v2));
1685-
for uint::range(0u, len(v1)) |i| {
1684+
assert!(v1.len() == v2.len());
1685+
for uint::range(0u, v1.len()) |i| {
16861686
if !f(&v1[i], &v2[i]) {
16871687
return false;
16881688
}
@@ -1699,6 +1699,35 @@ pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool {
16991699
_each2(v1, v2, f)
17001700
}
17011701
1702+
/**
1703+
*
1704+
* Iterates over two vector with mutable.
1705+
*
1706+
* # Failure
1707+
*
1708+
* Both vectors must have the same length
1709+
*/
1710+
#[inline]
1711+
pub fn _each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) -> bool {
1712+
assert!(v1.len() == v2.len());
1713+
for uint::range(0u, v1.len()) |i| {
1714+
if !f(&mut v1[i], &mut v2[i]) {
1715+
return false;
1716+
}
1717+
}
1718+
return true;
1719+
}
1720+
1721+
#[cfg(stage0)]
1722+
pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) {
1723+
_each2_mut(v1, v2, f);
1724+
}
1725+
1726+
#[cfg(not(stage0))]
1727+
pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T], f: &fn(u: &mut U, t: &mut T) -> bool) -> bool {
1728+
_each2_mut(v1, v2, f)
1729+
}
1730+
17021731
/**
17031732
* Iterate over all permutations of vector `v`.
17041733
*

branches/try2/src/libuv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 218ab86721eefd7b7e97fa6d9f95a80a1fa8686c
1+
Subproject commit 97ac7c087a0caf6b0f611b80e14f7fe3cb18bb27
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// -*- rust -*-
12+
fn main(){
13+
let mut t1 = ~[];
14+
t1.push('a');
15+
16+
let mut t2 = ~[];
17+
t2.push('b');
18+
19+
for vec::each2_mut(t1, t2) | i1, i2 | {
20+
assert!(*i1 == 'a');
21+
assert!(*i2 == 'b');
22+
}
23+
24+
for vec::each2(t1, t2) | i1, i2 | {
25+
io::println(fmt!("after t1: %?, t2: %?", i1, i2));
26+
}
27+
28+
for vec::each2_mut(t1, t2) | i1, i2 | {
29+
*i1 = 'b';
30+
*i2 = 'a';
31+
assert!(*i1 == 'b');
32+
assert!(*i2 == 'a');
33+
}
34+
35+
for vec::each2(t1, t2) | i1, i2 | {
36+
io::println(fmt!("before t1: %?, t2: %?", i1, i2));
37+
}
38+
}

0 commit comments

Comments
 (0)