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

Allow *local* mutation and assignments in pattern guards #23627

Closed
Stebalien opened this issue Mar 23, 2015 · 3 comments
Closed

Allow *local* mutation and assignments in pattern guards #23627

Stebalien opened this issue Mar 23, 2015 · 3 comments

Comments

@Stebalien
Copy link
Contributor

Due to #15989, it isn't possible to assign/mutate in pattern guards. However, assignment/mutation of variables local to the pattern guard should be perfectly safe.

As reported on reddit: https://pay.reddit.com/r/rust/comments/2ztiag/cannot_mutably_borrow_in_a_pattern_guard/ by qthree:

This code is failing: http://is.gd/cAYb5r But that's ok: http://is.gd/7pF28q

@steveklabnik
Copy link
Member

As this would be a language change / addition, it should be in the RFC repo instead. Please make an issue at https://github.com/rust-lang/rfcs/issues/new , thanks :)

(If you don't want to for some reason, I can, but if you make it, then you'll get notification with updates)

@Stebalien
Copy link
Contributor Author

Done (rust-lang/rfcs#1006). I'd write an actual RFC but I realized that I have no idea how to best implement this (other than wrap pattern guards in an Fn closure and ask on LLVM to inline it...).

@steveklabnik
Copy link
Member

super fair :)

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

No branches or pull requests

2 participants