Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pattern match #66

Closed
Kyuuhachi opened this issue Feb 14, 2024 · 1 comment · Fixed by #68
Closed

Cannot pattern match #66

Kyuuhachi opened this issue Feb 14, 2024 · 1 comment · Fixed by #68

Comments

@Kyuuhachi
Copy link

Consts of these types cannot be used in patterns.

const A: u7 = u7::new(127);

fn foo() {
	match u7::new(127) {
		A => {}
		_ => {}
	}
}
error: to use a constant of type `u7` in a pattern, `u7` must be annotated with `#[derive(PartialEq, Eq)]`
  --> src/lib.rs:85:3
   |
85 |         A => {}
   |         ^
   |
   = note: the traits must be derived, manual `impl`s are not sufficient
   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
@chrysn
Copy link
Member

chrysn commented Feb 14, 2024

Implementing identity through the derived form would fix this, but it's a decision we have so far deferred. I've opened up #67 to come to a conclusion. If the outcome is "commit to mask-before", we can make the identity the structural one, and thus enable matching.

chrysn added a commit to chrysn-pull-requests/uX that referenced this issue Feb 23, 2024
The derived implementations work now that the interior value is always
fully masked[1].

As a side effect, this makes consts eligible for pattern matching.

[1]: rust-ux#65

Close: rust-ux#66
chrysn added a commit to chrysn-pull-requests/uX that referenced this issue Feb 23, 2024
chrysn added a commit to chrysn-pull-requests/uX that referenced this issue Apr 11, 2024
chrysn added a commit to chrysn-pull-requests/uX that referenced this issue Apr 11, 2024
The derived implementations work now that the interior value is always
fully masked[1].

As a side effect, this makes consts eligible for pattern matching.

[1]: rust-ux#65

Closes: rust-ux#66
chrysn added a commit to chrysn-pull-requests/uX that referenced this issue Apr 11, 2024
chrysn added a commit to chrysn-pull-requests/uX that referenced this issue May 30, 2024
The derived implementations work now that the interior value is always
fully masked[1].

As a side effect, this makes consts eligible for pattern matching.

[1]: rust-ux#65

Closes: rust-ux#66
chrysn added a commit to chrysn-pull-requests/uX that referenced this issue May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants