更改示例代码错误

pull/1464/head
zrll_ 5 months ago committed by GitHub
parent 76062ee952
commit 76e9a8f724
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -201,9 +201,8 @@ if let Some(x) = some_option_value {
}
// let-else
let Some(x) = some_option_value {
println!("{}", x);
} else { return; }
let Some(x) = some_option_value else { return; }
println!("{}", x);
```
在上面的例子中,`if let`写法里的`x`只能在`if`分支内使用,而`let-else`写法里的`x`则可以在`let`之外使用。

Loading…
Cancel
Save