From 023e5af6398f8892fee429759096ba8c2480ed7d Mon Sep 17 00:00:00 2001 From: Roy Frostig Date: Mon, 28 Jun 2010 23:18:51 -0700 Subject: The few and proud isolated bits from stdlib-work so far that don't break everything. Note util.rs hasn't yet been declared mod in the std crate. Don't do that yet, as it breaks make check. --- src/lib/_vec.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib/_vec.rs') 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; +} -- cgit v1.2.3