2022-12-21 09:29:35 -06:00
|
|
|
#![feature(if_let_guard)]
|
|
|
|
|
2018-09-07 10:52:49 -05:00
|
|
|
enum VecWrapper { A(Vec<i32>) }
|
|
|
|
|
2022-12-21 09:29:35 -06:00
|
|
|
fn if_guard(x: VecWrapper) -> usize {
|
2018-09-07 10:52:49 -05:00
|
|
|
match x {
|
|
|
|
VecWrapper::A(v) if { drop(v); false } => 1,
|
2019-05-05 06:02:32 -05:00
|
|
|
//~^ ERROR cannot move out of `v` in pattern guard
|
2018-09-07 10:52:49 -05:00
|
|
|
VecWrapper::A(v) => v.len()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-21 09:29:35 -06:00
|
|
|
fn if_let_guard(x: VecWrapper) -> usize {
|
|
|
|
match x {
|
|
|
|
VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1,
|
|
|
|
//~^ ERROR cannot move out of `v` in pattern guard
|
|
|
|
VecWrapper::A(v) => v.len()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-07 10:52:49 -05:00
|
|
|
fn main() {
|
2022-12-21 09:29:35 -06:00
|
|
|
if_guard(VecWrapper::A(vec![107]));
|
|
|
|
if_let_guard(VecWrapper::A(vec![107]));
|
2018-09-07 10:52:49 -05:00
|
|
|
}
|