diff options
Diffstat (limited to 'src/lib/_vec.rs')
| -rw-r--r-- | src/lib/_vec.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs index c938e6fb..86733fb5 100644 --- a/src/lib/_vec.rs +++ b/src/lib/_vec.rs @@ -28,3 +28,14 @@ fn len[T](vec[T] v) -> uint { fn buf[T](vec[T] v) -> vbuf { ret rustrt.vec_buf[T](v); } + +// Ought to take mutable &vec[T] v and just mutate it instead of copy +// and return. Blocking on issue #89 for this. +fn grow[T](mutable vec[T] v, int n, T initval) -> vec[T] { + let int i = n; + while (i > 0) { + i -= 1; + v += vec(initval); + } + ret v; +} |