diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-03-17 18:17:27 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-03-17 18:17:27 -0700 |
| commit | 3ee4a15e5e1be8d1baa529ccf2c64ba4a88abc93 (patch) | |
| tree | d55aafc8851b696cfb4c13f3b709556c82c15298 | |
| parent | 35e9970e29cfc075968e3a1b9d4e1293ab7ab98b (diff) | |
| download | rust-3ee4a15e5e1be8d1baa529ccf2c64ba4a88abc93.tar.gz rust-3ee4a15e5e1be8d1baa529ccf2c64ba4a88abc93.zip | |
core: Don't copy elements in filter_map
| -rw-r--r-- | src/libcore/vec.rs | 4 |
1 files 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<T: copy, U: copy>(v: [const T], f: fn(T) -> option<U>) +fn filter_map<T: copy, U: copy>(v: [T], f: fn(T) -> option<U>) -> [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]; } } |
