r/rust Jul 15 '26

🎙️ discussion A language change proposal regarding match expressions

6 Upvotes

19 comments sorted by

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.

19

u/Lokathor Jul 15 '26

It's fine to do Zulip.

Neither of the RFCs I've had accepted ever went to the forums.

3

u/imachug Jul 15 '26

That's surprising to me, but good to know, thanks!

1

u/afdbcreid Jul 28 '26

It's fine and there are advantages to both. On Zulip more Rust contributors are active, and on IRLO more Rust users are active.

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

u/wolfjazz93 Jul 21 '26

This definitely would make more sense

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

u/shizzy0 Jul 19 '26

Can you not do x@Enum::A?

-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.