Skip to content

Commit

Permalink
properly recurse through references
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 29, 2023
1 parent 8590388 commit e2ac2c6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion text/0000-constants-in-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ Most of the values of primitive Rust types have structural equality (integers, `
When a constant `C` of type `T` is used as a pattern, we first check that `T: PartialEq`.
Furthermore we require that the value of `C` *has (recursive) structural equality*, which is defined recursively as follows:

- Integers, `bool` and `char` values, and references always have structural equality.
- Integers as well as `bool` and `char` values always have structural equality.
- Tuples, arrays, and slices have structural equality if all their fields/elements have structural equality.
(In particular, `()` and `[]` always have structural equality.)
- References have structural equality if the value they point to has structural equality.
- A value of `struct` or `enum` type has structural equality if its `PartialEq` behaves exactly like the one generated by `derive(PartialEq)`,
and all fields (for enums: of the active variant) have structural equality.
- A raw pointer has structural equality if it was defined as a constant integer (and then cast/transmuted).
Expand Down

0 comments on commit e2ac2c6

Please sign in to comment.