Add ivec::from_vec and ivec::to_vec
This commit is contained in:
parent
3595f1f966
commit
f3df9f50ea
1 changed files with 16 additions and 0 deletions
|
|
@ -19,6 +19,22 @@ native "rust" mod rustrt {
|
|||
count: uint);
|
||||
}
|
||||
|
||||
fn from_vec[T](v: &vec[T]) -> T[] {
|
||||
let iv: T[] = ~[];
|
||||
for e in v {
|
||||
iv += ~[e];
|
||||
}
|
||||
ret iv;
|
||||
}
|
||||
|
||||
fn to_vec[T](iv: &T[]) -> vec[T] {
|
||||
let v: vec[T] = [];
|
||||
for e in iv {
|
||||
v += [e];
|
||||
}
|
||||
ret v;
|
||||
}
|
||||
|
||||
/// Reserves space for `n` elements in the given vector.
|
||||
fn reserve[T](v: &mutable T[mutable? ], n: uint) {
|
||||
rustrt::ivec_reserve_shared(v, n);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue