我对 Rust 比较陌生,正在尝试执行以下操作:
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
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试构建它时,出现编译器错误:
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
}
}
}
Run Code Online (Sandbox Code Playgroud) rust ×1