45859b7ca7
Stabilize `bind_by_move_pattern_guards` in Rust 1.39.0 Closes https://github.com/rust-lang/rust/issues/15287. After stabilizing `#![feature(bind_by_move_pattern_guards)]`, you can now use bind-by-move bindings in patterns and take references to those bindings in `if` guards of `match` expressions. For example, the following now becomes legal: ```rust fn main() { let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]); match array { nums // ---- `nums` is bound by move. if nums.iter().sum::<u8>() == 10 // ^------ `.iter()` implicitly takes a reference to `nums`. => { drop(nums); // --------- Legal as `nums` was bound by move and so we have ownership. } _ => unreachable!(), } } ``` r? @matthewjasper |
||
---|---|---|
.. | ||
bind-by-move-no-guards.rs | ||
former-E0008-now-pass.rs | ||
rfc-basic-examples.rs | ||
rfc-reject-double-move-across-arms.rs | ||
rfc-reject-double-move-across-arms.stderr | ||
rfc-reject-double-move-in-first-arm.rs | ||
rfc-reject-double-move-in-first-arm.stderr |