I'm relatively new to Rust and am trying to do the following:
pub fn route(request: &[String]) {
let commands = ["one thing", "another thing", "something else"];
for command in commands.iter() {
if command == request {
// do something
} else {
// throw error
}
}
}
When I try to build this, I get a compiler error:
error[E0277]: the trait bound `&str: std::cmp::PartialEq<[std::string::String]>` is not satisfied
--> src/main.rs:5:20
|
5 | if command == request {
| ^^ can't compare `&str` with `[std::string::String]`
|
= help: the trait `std::cmp::PartialEq<[std::string::String]>` is not implemented for `&str`
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&[std::string::String]>` for `&&str`