diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-07-29 13:46:53 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-07-29 14:05:04 -0700 |
| commit | f3df9f50ea8fb136767677821ce433bc7ec188fb (patch) | |
| tree | 2fa5e58de0fdd881adf20cb321251b620b30f1c7 | |
| parent | 3595f1f966227022164dc2e1e7b0d90e6d667899 (diff) | |
| download | rust-f3df9f50ea8fb136767677821ce433bc7ec188fb.tar.gz rust-f3df9f50ea8fb136767677821ce433bc7ec188fb.zip | |
Add ivec::from_vec and ivec::to_vec
| -rw-r--r-- | src/lib/ivec.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/ivec.rs b/src/lib/ivec.rs index eed4837d83f..6d12d550625 100644 --- a/src/lib/ivec.rs +++ b/src/lib/ivec.rs @@ -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); |
