]> git.lizzy.rs Git - rust.git/commitdiff
Make std:vec::grow_fn take an init_op type
authorBrian Anderson <banderson@mozilla.com>
Fri, 28 Oct 2011 00:06:49 +0000 (17:06 -0700)
committerBrian Anderson <banderson@mozilla.com>
Fri, 28 Oct 2011 00:06:49 +0000 (17:06 -0700)
src/lib/vec.rs

index fd6e594e1ad0a19ef39a57615d5c47b989a9b65c..76ce8eeac257e794e8448d26a2f9cbf6ca1bca7e 100644 (file)
@@ -337,10 +337,10 @@ fn grow_mut<T>(&v: [mutable T], n: uint, initval: T) {
 n - The number of elements to add
 init_fn - A function to call to retreive each appended element's value
 */
-fn grow_fn<T>(&v: [T], n: uint, init_fn: block(uint) -> T) {
+fn grow_fn<T>(&v: [T], n: uint, op: init_op<T>) {
     reserve(v, next_power_of_two(len(v) + n));
     let i: uint = 0u;
-    while i < n { v += [init_fn(i)]; i += 1u; }
+    while i < n { v += [op(i)]; i += 1u; }
 }
 
 /*