Skip to content

Commit af2345e

Browse files
committed
Unwrap all lines in the non_exhaustive sections
1 parent 011cbb6 commit af2345e

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

src/attributes/type_system.md

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ r[attributes.type-system.non_exhaustive]
77
## The `non_exhaustive` attribute
88

99
r[attributes.type-system.non_exhaustive.intro]
10-
The *`non_exhaustive` attribute* indicates that a type or variant may have
11-
more fields or variants added in the future.
10+
The *`non_exhaustive` attribute* indicates that a type or variant may have more fields or variants added in the future.
1211

1312
> [!EXAMPLE]
1413
> The following non-exhaustive definitions will be used in the examples that follow.
@@ -43,8 +42,7 @@ r[attributes.type-system.non_exhaustive.allowed-positions]
4342
It can be applied to [`struct`s][struct], [`enum`s][enum], and `enum` variants.
4443
4544
r[attributes.type-system.non_exhaustive.syntax]
46-
The `non_exhaustive` attribute uses the [MetaWord] syntax and thus does not
47-
take any inputs.
45+
The `non_exhaustive` attribute uses the [MetaWord] syntax and thus does not take any inputs.
4846
4947
r[attributes.type-system.non_exhaustive.same-crate]
5048
Within the defining crate, `non_exhaustive` has no effect.
@@ -82,20 +80,13 @@ Within the defining crate, `non_exhaustive` has no effect.
8280
8381
8482
r[attributes.type-system.non_exhaustive.external-crate]
85-
Outside of the defining crate, types annotated with `non_exhaustive` have limitations that
86-
preserve backwards compatibility when new fields or variants are added.
83+
Outside of the defining crate, types annotated with `non_exhaustive` have limitations that preserve backwards compatibility when new fields or variants are added.
8784
8885
r[attributes.type-system.non_exhaustive.construction]
8986
Non-exhaustive types cannot be constructed outside of the defining crate:
9087
91-
- Non-exhaustive variants ([`struct`][struct] or [`enum` variant][enum]) cannot be constructed
92-
with a [StructExpression] \(including with [functional update syntax]).
93-
- The implicitly defined same-named constant of a [unit-like struct][struct],
94-
or the same-named constructor function of a [tuple struct][struct],
95-
has a [visibility] no greater than `pub(crate)`.
96-
That is, if the structs visibility is `pub`, then the constant or constructors visibility
97-
is `pub(crate)`, and otherwise the visibility of the two items is the same
98-
(as is the case without `#[non_exhaustive]`).
88+
- Non-exhaustive variants ([`struct`][struct] or [`enum` variant][enum]) cannot be constructed with a [StructExpression] \(including with [functional update syntax]).
89+
- The implicitly defined same-named constant of a [unit-like struct][struct], or the same-named constructor function of a [tuple struct][struct], has a [visibility] no greater than `pub(crate)`. That is, if the structs visibility is `pub`, then the constant or constructors visibility is `pub(crate)`, and otherwise the visibility of the two items is the same (as is the case without `#[non_exhaustive]`).
9990
- [`enum`][enum] instances can be constructed.
10091
10192
> [!EXAMPLE]
@@ -141,11 +132,8 @@ Non-exhaustive types cannot be constructed outside of the defining crate:
141132
r[attributes.type-system.non_exhaustive.match]
142133
There are limitations when matching on non-exhaustive types outside of the defining crate:
143134
144-
- When pattern matching on a non-exhaustive variant ([`struct`][struct] or [`enum` variant][enum]),
145-
a [StructPattern] must be used which must include a `..`. A tuple enum variant's constructor's
146-
[visibility] is reduced to be no greater than `pub(crate)`.
147-
- When pattern matching on a non-exhaustive [`enum`][enum], matching on a variant does not
148-
contribute towards the exhaustiveness of the arms.
135+
- When pattern matching on a non-exhaustive variant ([`struct`][struct] or [`enum` variant][enum]), a [StructPattern] must be used which must include a `..`. A tuple enum variant's constructor's [visibility] is reduced to be no greater than `pub(crate)`.
136+
- When pattern matching on a non-exhaustive [`enum`][enum], matching on a variant does not contribute towards the exhaustiveness of the arms.
149137
150138
> [!EXAMPLE]
151139
> Using the definitions from [above][attributes.type-system.non_exhaustive.intro], the following examples of matching do not compile when outside the defining crate:

0 commit comments

Comments
 (0)