I am working on a program in Rust and I am getting stuck on match
. I currently have
extern crate regex;
use std::collections::HashMap;
fn main() {
let s = "";
let re = regex::Regex::new(r"[^A-Za-z0-9\w'").unwrap();
let s = re.split(s).collect::<Vec<&str>>();
let mut h: HashMap<String, u32> = HashMap::new();
for x in s {
match h.get(x) {
Some(i) => h.entry(x.to_string()).or_insert_with(i + 1),
None => h.entry(x.to_string()).or_insert_with(1),
}
}
}
but when I run this I get a whole litany of errors, including
error: the trait bound `u32: std::ops::FnOnce<()>` is not satisfied [E0277]
Some(i) => h.entry(x.to_string()).or_insert_with(i + 1),
^~~~~~~~~~~~~~
and I'm not exactly sure where to go with this.