Could someone explain me why does it say that *profession
is a unit type while it is a vector?
use hashbrown::HashMap;
fn main() {
let mut sphere: HashMap<String, Vec<&str>> = HashMap::new();
sphere.insert(String::from("junior"), vec![]);
sphere.insert(String::from("Middle"), vec![]);
sphere.insert(String::from("Senior"), vec![]);
loop {
println!();
let mut input = String::new();
std::io::stdin()
.read_line(&mut input)
.expect("What the hell this doesn't work!?");
if input.trim() == "stop" {
break;
}
let splited_data: Vec<&str> = input.split(" to ").collect();
let person = splited_data[0];
let category = splited_data[1].to_string();
let professions = sphere.entry(category.to_string()).or_insert(vec![]);
*professions.push(person);
}
}
error[E0614]: type `()` cannot be dereferenced
--> src/lib.rs:21:9
|
21 | *professions.push(person);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error