Skip to content

Commit 341f86d

Browse files
committed
Use a simpler example of let chains
1 parent d9311b6 commit 341f86d

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

content/Rust-1.88.0.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ For more information, see the original [unstable announcement](https://blog.rust
3636

3737
This feature allows `&&`-chaining `let` statements inside `if` and `while` conditions, even intermingling with boolean expressions, so there is less distinction between `if`/`if let` and `while`/`while let`. The patterns inside the `let` sub-expressions can be irrefutable or refutable, and bindings are usable in later parts of the chain as well as the body.
3838

39-
For example, [this actual snippet](https://github.com/rust-lang/rust/blob/28f1c807911c63f08d98e7b468cfcf15a441e34b/compiler/rustc_ast_passes/src/feature_gate.rs#L327-L338) from the compiler combines multiple conditions which would have required nesting `if let` and `if` blocks before:
39+
For example, this snippet combines multiple conditions which would have required nesting `if let` and `if` blocks before:
4040

4141
```rust
42-
fn visit_generic_args(&mut self, args: &'a ast::GenericArgs) {
43-
if let ast::GenericArgs::Parenthesized(generic_args) = args
44-
&& let ast::FnRetTy::Ty(ref ty) = generic_args.output
45-
&& matches!(ty.kind, ast::TyKind::Never)
46-
{
47-
gate!(&self, never_type, ty.span, "the `!` type is experimental");
48-
}
49-
visit::walk_generic_args(self, args);
50-
}
42+
if let Channel::Stable(v) = release_info()
43+
&& let Semver { major, minor, .. } = v
44+
&& major == 1
45+
&& minor == 88
46+
{
47+
println!("`let_chains` was stabilized in this version");
48+
}
5149
```
5250

5351
Let chains are only available in the Rust 2024 edition, as this feature depends on the [`if let` temporary scope](https://doc.rust-lang.org/edition-guide/rust-2024/temporary-if-let-scope.html) change for more consistent drop order.

0 commit comments

Comments
 (0)