I'm a newbie in Rust.
My code inside a function that returns Option<(SomeType, String)>
looks like this:
let mut keywords: HashMap<String, SomeType> = HashMap::new();
keywords.insert("a".to_string(), SomeType::A);
keywords.insert("b".to_string(), SomeType::B);
keywords.insert("c".to_string(), SomeType::C);
match keywords.get("a") {
Some(some_type) => {
// do something
return Some((some_type, "some string".to_string()));
}
_ => { return None }
}
When I tried to run this, the compiler throw this error:
expected enum `SomeType`, found `&SomeType`
So, I tried this:
return Some((*some_type, "some string".to_string()));
But now, the compiler throws this error:
move occurs because `*some_type` has type `SomeType`, which does not implement the `Copy` trait
How can I solve this??