File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 397f33fd35558fd0c390ae29839ecbaf7ce456f9
2
+ refs/heads/master: e4af1ca0657d2b3b4fc2e7829cd8f822d983de1b
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Original file line number Diff line number Diff line change @@ -323,6 +323,11 @@ fn shift<T: copy>(&v: [const T]) -> T {
323
323
ret e;
324
324
}
325
325
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
+
326
331
#[ doc = "Remove the last element from a vector and return it" ]
327
332
fn pop< T > ( & v: [ const T ] ) -> T unsafe {
328
333
let ln = len ( v) ;
@@ -1734,6 +1739,13 @@ mod tests {
1734
1739
let addr_imm = unsafe :: to_ptr ( x_imm) ;
1735
1740
assert addr == addr_imm;
1736
1741
}
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
+ }
1737
1749
}
1738
1750
1739
1751
// Local Variables:
You can’t perform that action at this time.
0 commit comments