]> git.lizzy.rs Git - rust.git/blob - src/test/ui/by-move-pattern-binding.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / by-move-pattern-binding.rs
1 enum E {
2     Foo,
3     Bar(String)
4 }
5
6 struct S {
7     x: E
8 }
9
10 fn f(x: String) {}
11
12 fn main() {
13     let s = S { x: E::Bar("hello".to_string()) };
14     match &s.x { //~ ERROR cannot move
15         &E::Foo => {}
16         &E::Bar(identifier) => f(identifier.clone())
17     };
18     match &s.x {
19         &E::Foo => {}
20         &E::Bar(ref identifier) => println!("{}", *identifier)
21     };
22 }