Skip to content

Commit f010f79

Browse files
committed
Add std::ivec::to_mut, from_mut
1 parent 8c4f165 commit f010f79

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/lib/ivec.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ fn init_elt_mut[T](&T t, uint n_elts) -> T[mutable] {
7272
ret v;
7373
}
7474

75+
fn to_mut[T](&T[] v) -> T[mutable] {
76+
auto vres = ~[mutable];
77+
for (T t in v) {
78+
vres += ~[mutable t];
79+
}
80+
ret vres;
81+
}
82+
83+
fn from_mut[T](&T[mutable] v) -> T[] {
84+
auto vres = ~[];
85+
for (T t in v) {
86+
vres += ~[t];
87+
}
88+
ret vres;
89+
}
90+
7591
// Predicates
7692
pred is_empty[T](&T[mutable?] v) -> bool {
7793
// FIXME: This would be easier if we could just call len

0 commit comments

Comments
 (0)