Skip to content

Commit 10cadcd

Browse files
committed
---
yaml --- r: 24220 b: refs/heads/master c: 2340ef9 h: refs/heads/master v: v3
1 parent 9dc32a8 commit 10cadcd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7f7af5f2ceedf533d2d09a1a2afd8b53031e5a9a
2+
refs/heads/master: 2340ef96d54d488c53eeab1967a2347aebde38ca
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/vec.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ impl<T: Copy> &[const T]: CopyableVector<T> {
15261526
}
15271527

15281528
trait ImmutableVector<T> {
1529+
pure fn view(start: uint, end: uint) -> &[T];
15291530
pure fn foldr<U: Copy>(z: U, p: fn(T, U) -> U) -> U;
15301531
pure fn map<U>(f: fn(v: &T) -> U) -> ~[U];
15311532
pure fn mapi<U>(f: fn(uint, v: &T) -> U) -> ~[U];
@@ -1544,6 +1545,10 @@ trait ImmutableEqVector<T: Eq> {
15441545

15451546
/// Extension methods for vectors
15461547
impl<T> &[T]: ImmutableVector<T> {
1548+
/// Return a slice that points into another slice.
1549+
pure fn view(start: uint, end: uint) -> &[T] {
1550+
view(self, start, end)
1551+
}
15471552
/// Reduce a vector from right to left
15481553
#[inline]
15491554
pure fn foldr<U: Copy>(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) }
@@ -2804,17 +2809,14 @@ mod tests {
28042809
assert capacity(v) == 10u;
28052810
}
28062811

2807-
/*
28082812
#[test]
2809-
#[ignore] // region inference doesn't work well enough for this yet.
28102813
fn test_view() {
28112814
let v = ~[1, 2, 3, 4, 5];
2812-
let v = view(v, 1u, 3u);
2815+
let v = v.view(1u, 3u);
28132816
assert(len(v) == 2u);
28142817
assert(v[0] == 2);
28152818
assert(v[1] == 3);
28162819
}
2817-
*/
28182820
}
28192821

28202822
// Local Variables:

0 commit comments

Comments
 (0)