Skip to content

Commit a006a42

Browse files
committed
---
yaml --- r: 11961 b: refs/heads/master c: e4af1ca h: refs/heads/master i: 11959: ff58b7b v: v3
1 parent dfff142 commit a006a42

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
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: 397f33fd35558fd0c390ae29839ecbaf7ce456f9
2+
refs/heads/master: e4af1ca0657d2b3b4fc2e7829cd8f822d983de1b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/vec.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ fn shift<T: copy>(&v: [const T]) -> T {
323323
ret e;
324324
}
325325

326+
#[doc = "Prepend an element to a vector"]
327+
fn unshift<T: copy>(&v: [const T], +t: T) {
328+
v = [const t] + v;
329+
}
330+
326331
#[doc = "Remove the last element from a vector and return it"]
327332
fn pop<T>(&v: [const T]) -> T unsafe {
328333
let ln = len(v);
@@ -1734,6 +1739,13 @@ mod tests {
17341739
let addr_imm = unsafe::to_ptr(x_imm);
17351740
assert addr == addr_imm;
17361741
}
1742+
1743+
#[test]
1744+
fn test_unshift() {
1745+
let x = [1, 2, 3];
1746+
unshift(x, 0);
1747+
assert x == [0, 1, 2, 3];
1748+
}
17371749
}
17381750

17391751
// Local Variables:

0 commit comments

Comments
 (0)