You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: posts/2024-10-17-Rust-1.82.0.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,33 +57,33 @@ The Rust target `aarch64-apple-darwin` for macOS on ARM64 (M1-family or later Ap
57
57
58
58
[The targets](https://doc.rust-lang.org/nightly/rustc/platform-support/apple-ios-macabi.html) are now tier 2, and can be downloaded with `rustup target add aarch64-apple-ios-macabi x86_64-apple-ios-macabi`, so now is an excellent time to update your CI pipeline to test that your code also runs in iOS-like environments.
59
59
60
-
### Minimal exhaustive patterns
60
+
### Omitting empty types in pattern matching
61
61
62
-
Empty patterns can now be omitted in common cases:
62
+
Patterns which match empty (a.k.a. uninhabited) types by value can now be omitted:
letOk(x) =x; // the `Err` case does not need to appear
68
68
x
69
69
}
70
70
```
71
71
72
72
This works with empty types such as a variant-less `enum Void {}`, or structs and enums with a visible empty field and no `#[non_exhaustive]` attribute. It will also be particularly useful in combination with the never type `!`, although that type is still unstable at this time.
73
73
74
-
This feature is "minimal" because there are still some exclusions at this time. For reasons related to uninitialized values and unsafe code, omitting patterns is not allowed if the empty type is accessed through a reference, pointer, or union field:
74
+
There are still some cases where empty patterns must still be written. For reasons related to uninitialized values and unsafe code, omitting patterns is not allowed if the empty type is accessed through a reference, pointer, or union field:
// this branch cannot be omitted because of the reference
80
+
// this arm cannot be omitted because of the reference
81
81
Err(infallible) =>match*infallible {},
82
82
}
83
83
}
84
84
```
85
85
86
-
To avoid interfering with crates that wish to support several rust versions, branches with empty patterns are not yet warned as "unreachable", despite the fact that they can be removed.
86
+
To avoid interfering with crates that wish to support several Rust versions, `match` arms with empty patterns are not yet reported as “unreachable code” warnings, despite the fact that they can be removed.
0 commit comments