The following does not compile:
let foo = vec!["hi".to_string()];
if foo.contains("hi") {
println!("yes");
}
citing
|
147 | if foo.contains("hi") {
| ^^^^ expected struct `String`, found `str`
|
= note: expected reference `&String`
found reference `&'static str`
Assuming that in the real problem I have no control of the type of the Vec<String>, is it possible to search through structures (Vecs, Sets, HashMaps, etc.) via a &str, when the structure contains owned strings?
I know that I could just clone() the &str before lookup, but I'd rather not. Any ideas?