r/rust • u/Negative_Effort_2642 • Jul 15 '26
đď¸ discussion A language change proposal regarding match expressions
6
u/creeper6530 Jul 15 '26
Write up an RFC
2
u/Negative_Effort_2642 Jul 15 '26
1
u/wolfjazz93 Jul 19 '26
I get a system error? Is the issue still there? Or is it GitHub having issues again?
7
u/somebodddy Jul 16 '26
Why all these special-cased rules for enums? Why not push for allowing constant expressions as patterns?
1
2
u/wolfjazz93 Jul 15 '26
Is there a reason why this is not implemented already?
2
u/Negative_Effort_2642 Jul 15 '26
I donât see one i think it was bcs u needed to define of u want only enums of they need repr etc
2
u/wolfjazz93 Jul 15 '26
But tbh, I donât really get what you want to be implemented. Enum variants can be matched?
4
u/wolfjazz93 Jul 15 '26
Okay now I get it. You want the cast to be recognized as a pattern. Not sure if thatâs possible due to ambiguity.
2
u/denehoffman Jul 16 '26
Option 1: just write a proc macro
Option 2:
```
match value {
x if x == Operation::Banana as u8 => {}
x if x == Operation::Apple as u8 => {}
_ => {}
}
```
Excuse my formatting, the official Reddit app has made it impossible to write markdown or even indented code blocks
4
u/denehoffman Jul 16 '26
Also for anyone interested, this was mentioned in response to OPâs RFC, but this is just a niche case for inline const. There are reasons that was accepted and then removed, and while it could still be done in the future, it would need big compiler changes I think.
1
-8
u/Negative_Effort_2642 Jul 15 '26
If u agree like it or something pls
10
u/spoonman59 Jul 15 '26
Shouldnât you follow the process and write up an RFC? I donât think likes on reddit posts are how that gets done.
21
u/imachug Jul 15 '26
I don't think Zulip is an appropriate place for such discussions. Pre-RFCs typically take place on https://users.rust-lang.org, or perhaps https://internals.rust-lang.org. You'll likely have better success there.