title: How to fold using a HashMap as an accumulator?
body: <p>This code works:</p>
  
  <pre><code>let stdin = std::io::stdin();
  let mut rdr = csv::Reader::from_reader(stdin);
  let mut hmap = HashMap::&lt;String, u64&gt;::new();
  
  rdr.records()
      .map(|r| r.unwrap())
      .fold((), |_, item| {
          // TODO: Is there a way not to have to copy item[col] every time?
          let counter = hmap.entry(item[col].to_string()).or_insert(0);
          *counter += 1;
      });
  </code></pre>
  
  <p>This code fails with the message: "cannot move out of <code>acc</code> because it is borrowed"</p>
  
  <pre><code>let stdin = std::io::stdin();
  let mut rdr = csv::Reader::from_reader(stdin);
  let hmap = rdr.records()
      .map(|r| r.unwrap())
      .fold(HashMap::&lt;String, u64&gt;::new(), |mut acc, item| {
          // TODO: Is there a way not to have to copy item[col] every time?
          let counter = acc.entry(item[col].to_string()).or_insert(0);
          *counter += 1;
          acc
      });
  </code></pre>