Skip to content

Commit 0b764ca

Browse files
committed
small fixes and clarifications
1 parent 6b8cc0a commit 0b764ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

text/0000-constants-in-patterns.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ This new RFC takes the stance it does the former based on the following main des
5656
[guide-level-explanation]: #guide-level-explanation
5757

5858
Constants can be used as patterns, but only if their type implements `PartialEq`.
59-
Moreover, this implementation must be the automatically derived one, and that also applies recursively for the types of their fields (recursively):
59+
Moreover, this implementation must be the automatically derived one, and that also applies recursively for the types of their fields:
6060

6161
```rust
6262
#[derive(PartialEq)] // code fails to build if we remove this or replace it by a manual impl
@@ -101,11 +101,11 @@ This means the eligibility of a constant for a pattern depends on its value, not
101101
That is already the case on stable Rust for many years and relied upon by widely-used crates such as [`http`](https://github.com/rust-lang/rust/issues/62411#issuecomment-510604193).
102102

103103
Overall we say that the *value* of the constant must have recursive structural equality,
104-
which is the case when all the types that actually appear recursively in the type (ignoring "other" enum variants) have structural equality.
104+
which is the case when all the types that actually appear recursively in the value (ignoring "other" enum variants) have structural equality.
105105

106106
Most of the values of primitive Rust types have structural equality (integers, `bool`, `char`, references), but two families of types need special consideration:
107107

108-
- Pointer types (raw pointers and function pointers): these compare by test the memory address for equality.
108+
- Pointer types (raw pointers and function pointers): these compare by testing the memory address for equality.
109109
It is unclear whether that should be considered "structural", but it is fairly clear that this should be considered a bad idea:
110110
Rust makes basically no guarantees for when two function pointers are equal or unequal
111111
(the "same" function can be duplicated across codegen units and this have different addresses,
@@ -184,7 +184,7 @@ Range patterns are only allowed on integers, `char`, and floats; for floats, nei
184184

185185
The *behavior* of such a constant as a pattern is the same as the corresponding native pattern.
186186
On floats are raw pointers, pattern matching behaves like `==`,
187-
which means in particular that the value `-0.0` matches the pattern `0.0`, and NaN values match no pattern.
187+
which means in particular that the value `-0.0` matches the pattern `0.0`, and NaN values match no pattern (except for wildcards).
188188

189189
## Breaking changes
190190

0 commit comments

Comments
 (0)