以下代码无法编译:
fn testing() -> i32 {
let x = 5;
if x == 5 {
5
}
6
}
Run Code Online (Sandbox Code Playgroud)
出现此错误:
fn testing() -> i32 {
let x = 5;
if x == 5 {
5
}
6
}
Run Code Online (Sandbox Code Playgroud)
如果我return在 前面放了一个显式5,或者如果我把6里面放了一个else块,一切正常。Rust 到底在抱怨什么?