我是一个Rust初学者,无法解决这个类型问题。我已经尝试用name
替换&name
,但出现了错误“模式&_
未覆盖”。
fn get_project(name: &'static str) {
match &name {
"hi" => {},
}
}
fn main() {
let project = get_project("hi");
}
编译错误:
error[E0308]: mismatched types
--> <anon>:3:9
|
3 | "hi" => {},
| ^^^^ expected &str, found str
|
= note: expected type `&&str`
= note: found type `&'static str`