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: src/attributes/type_system.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -163,7 +163,7 @@ match message {
163
163
}
164
164
```
165
165
166
-
In Rust, casting non-exhaustive types from foreign crates is generally disallowed, except when dealing with enums that have no non-exhaustive variants.
166
+
However, casting non-exhaustive types from foreign crates is generally disallowed, except when dealing with enums that have no non-exhaustive variants.
167
167
168
168
For example, the following enum can be cast because it doesn't contain any non-exhaustive variants:
169
169
```rust, ignore
@@ -186,10 +186,10 @@ pub enum Example {
186
186
```
187
187
188
188
```rust, ignore
189
-
use othercrate::NonExhaustiveEnumVariants;
189
+
use othercrate::EnumWithNonExhaustiveEnumVariants;
190
190
191
-
// cannot cast an enum with a non-exhaustive variant when it's defined in another crate
192
-
let _ = NonExhaustiveEnum::default() as u8;
191
+
// Error: cannot cast an enum with a non-exhaustive variant when it's defined in another crate
192
+
let _ = EnumWithNonExhaustiveEnumVariants::default() as u8;
193
193
```
194
194
195
195
Non-exhaustive types are always considered inhabited in downstream crates.
0 commit comments