We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12f6e86 commit a6b2a2cCopy full SHA for a6b2a2c
src/lib/vec.rs
@@ -384,7 +384,19 @@ Function: map
384
385
Apply a function to each element of a vector and return the results
386
*/
387
-fn map<copy T, U>(f: block(T) -> U, v: [const T]) -> [U] {
+fn map<T, U>(f: block(T) -> U, v: [T]) -> [U] {
388
+ let result = [];
389
+ reserve(result, len(v));
390
+ for elem: T in v { result += [f(elem)]; }
391
+ ret result;
392
+}
393
+
394
+/*
395
+Function: map_mut
396
397
+Apply a function to each element of a mutable vector and return the results
398
+*/
399
+fn map_mut<copy T, U>(f: block(T) -> U, v: [const T]) -> [U] {
400
let result = [];
401
reserve(result, len(v));
402
for elem: T in v {
0 commit comments