Skip to content

Commit 110a507

Browse files
committed
---
yaml --- r: 59112 b: refs/heads/incoming c: 943b9d5 h: refs/heads/master v: v3
1 parent c464803 commit 110a507

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 8291e36f184b2a72eaae8fa745759a09c17c8db8
9+
refs/heads/incoming: 943b9d5dd9edacded3c763f399b4ea13fb2437bd
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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
*

0 commit comments

Comments
 (0)