From 3ee4a15e5e1be8d1baa529ccf2c64ba4a88abc93 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 17 Mar 2012 18:17:27 -0700 Subject: [PATCH] core: Don't copy elements in filter_map --- src/libcore/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index d69507b75c1..6beda8306e2 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -430,11 +430,11 @@ Apply a function to each element of a vector and return the results If function `f` returns `none` then that element is excluded from the resulting vector. "] -fn filter_map(v: [const T], f: fn(T) -> option) +fn filter_map(v: [T], f: fn(T) -> option) -> [U] { let mut result = []; for elem: T in v { - alt f(copy elem) { + alt f(elem) { none {/* no-op */ } some(result_elem) { result += [result_elem]; } }