1 In a pattern, all values that don't implement the `Copy` trait have to be bound
2 the same way. The goal here is to avoid binding simultaneously by-move and
5 This limitation may be removed in a future version of Rust.
7 Erroneous code example:
12 let x = Some((X { x: () }, X { x: () }));
14 Some((y, ref z)) => {}, // error: cannot bind by-move and by-ref in the
20 You have two solutions:
22 Solution #1: Bind the pattern's values the same way.
27 let x = Some((X { x: () }, X { x: () }));
29 Some((ref y, ref z)) => {},
30 // or Some((y, z)) => {}
35 Solution #2: Implement the `Copy` trait for the `X` structure.
37 However, please keep in mind that the first solution should be preferred.
40 #[derive(Clone, Copy)]
43 let x = Some((X { x: () }, X { x: () }));
45 Some((y, ref z)) => {},