about summary refs log tree commit diff
path: root/src/libtest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-05 00:26:28 +0000
committerbors <bors@rust-lang.org>2015-01-05 00:26:28 +0000
commitad9e759382ad7daed26f86732f41f5f83cd673e2 (patch)
treef5a33b685a2c86a1a9a75ebf3cf5e1f9322431cd /src/libtest
parent5773bdefff2e47cc007f5cc2af3f80b30303d45a (diff)
parent400c3a0ddcf4441f66eb4653c7365b663f9a4ea1 (diff)
auto merge of #20163 : bfops/rust/master, r=Gankro
TODOs:
  - ~~Entry is still `<'a, K, V>` instead of `<'a, O, V>`~~
  - ~~BTreeMap is still outstanding~~.
  - ~~Transform appropriate things into `.entry(...).get().or_else(|e| ...)`~~

Things that make me frowny face:
  - I'm not happy about the fact that this `clone`s the key even when it's already owned.
  - With small keys (e.g. `int`s), taking a reference seems wasteful.

r? @Gankro
cc: @cgaebel
Diffstat (limited to 'src/libtest')
-rw-r--r--src/libtest/stats.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs
index 35af0e763d7..7e7f36f6e83 100644
--- a/src/libtest/stats.rs
+++ b/src/libtest/stats.rs
@@ -438,12 +438,14 @@ pub fn write_boxplot<W: Writer, T: Float + Show + FromPrimitive>(
 
 /// Returns a HashMap with the number of occurrences of every element in the
 /// sequence that the iterator exposes.
-pub fn freq_count<T: Iterator<Item=U>, U: Eq+Hash>(mut iter: T) -> hash_map::HashMap<U, uint> {
+pub fn freq_count<T, U>(mut iter: T) -> hash_map::HashMap<U, uint>
+  where T: Iterator<Item=U>, U: Eq + Clone + Hash
+{
     let mut map: hash_map::HashMap<U,uint> = hash_map::HashMap::new();
     for elem in iter {
-        match map.entry(elem) {
+        match map.entry(&elem) {
             Occupied(mut entry) => { *entry.get_mut() += 1; },
-            Vacant(entry) => { entry.set(1); },
+            Vacant(entry) => { entry.insert(1); },
         }
     }
     map