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: 71de17d38ee8db40e5f50d2ce8986e9676767309
2
+ refs/heads/master: e56a1720e4dd35f9143fc0620083b406c797fb9c
Original file line number Diff line number Diff line change
1
+ import option. none ;
2
+ import option. some ;
3
+
1
4
import vbuf = rustrt. vbuf ;
2
5
3
6
type operator2[ T , U , V ] = fn ( & T , & U ) -> V ;
@@ -115,6 +118,15 @@ fn print_debug_info[T](vec[mutable? T] v) {
115
118
rustrt. vec_print_debug_info [ T ] ( v) ;
116
119
}
117
120
121
+ // Returns the last element of v.
122
+ fn last[ T ] ( vec[ mutable? T ] v) -> option. t [ T ] {
123
+ auto l = len[ T ] ( v) ;
124
+ if ( l == 0 u) {
125
+ ret none[ T ] ;
126
+ }
127
+ ret some[ T ] ( v. ( l - 1 u) ) ;
128
+ }
129
+
118
130
// Returns elements from [start..end) from v.
119
131
fn slice[ T ] ( vec[ mutable? T ] v, uint start, uint end) -> vec[ T ] {
120
132
check ( start <= end) ;
You can’t perform that action at this time.
0 commit comments