@@ -113,37 +113,50 @@ putting the condition inside the body of the arm.
113113"## ,
114114
115115E0009 : r##"
116- In a pattern, all values that don't implement the Copy trait have to be binded the same way
117- than the others. The goal here is to avoid to bind by-move and by-ref at the same time.
116+ In a pattern, all values that don't implement the `Copy` trait have to be bound
117+ the same way. The goal here is to avoid binding simultaneous by-move and by-ref.
118+
119+ This limitation may be removed in a future version of Rust.
120+
118121Wrong example:
122+
123+ ```
119124struct X { x: (), }
120125
121126let x = Some((X { x: () }, X { x: () }));
122127match x {
123- Some((_y , ref _z )) => {},
128+ Some((y , ref z )) => {},
124129 None => panic!()
125130}
131+ ```
126132
127133You have two solutions:
128- * implement the Copy trait on the X structure:
129- #[derive(Clone, Copy)]
134+ 1. Bind the pattern's values the same way:
135+
136+ ```
130137struct X { x: (), }
131138
132139let x = Some((X { x: () }, X { x: () }));
133140match x {
134- Some((_y, ref _z)) => {},
141+ Some((ref y, ref z)) => {},
142+ // or Some((y, z)) => {}
135143 None => panic!()
136144}
145+ ```
146+
147+ 2. Implement the `Copy` trait for the X structure (however, please
148+ keep in mind that the first solution should be preferred!):
137149
138- * bind the the pattern's values the same way:
150+ ```
151+ #[derive(Clone, Copy)]
139152struct X { x: (), }
140153
141154let x = Some((X { x: () }, X { x: () }));
142155match x {
143- Some((ref _y, ref _z)) => {},
144- // or Some((_y, _z)) => {}
156+ Some((y, ref z)) => {},
145157 None => panic!()
146158}
159+ ```
147160"## ,
148161
149162E0162 : r##"
0 commit comments