-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Match with functions: first arm always triggered #44333
Comments
In your code, match test(rng.gen()) {
f if f == minus => println!("minus"),
f if f == plus => println!("plus"),
_ => println!("other"),
} Note that the return value of Pattern matching is different from comparing with
|
Yes with guards it works, but I suspect it changes the semantics of match (less optimizations I guess). |
You can normally use constants, but these currently fail: https://play.rust-lang.org/?gist=ad06b52140cf452e1e442153f0ac95f9&version=stable I guess noone thought that functions would be used in patterns:
|
That's much getter, imho. Thanks for hint.
Functions as values? Never heard of heresy like that :) |
Reduced the testcase. https://play.rust-lang.org/?gist=b2f649febb256d6fb443b014e38ea6c0&version=stable |
The test cases here no longer ICE on beta or nightly. |
Needs a regression test |
Added regression function match value test closes rust-lang#44333
Hi all
Following code produces always the same output in console and emits
... in compilation.
Tested in Rust playground in nightly.
Any comments?
The text was updated successfully, but these errors were encountered: