I have a struct:
struct ThreeDPoint {
x: f32,
y: f32,
z: f32
}
and I want to extract two of the three properties after instantiating it:
let point: ThreeDPoint = ThreeDPoint { x: 0.3, y: 0.4, z: 0.5 };
let ThreeDPoint { x: my_x, y: my_y } = point;
The compiler throws the following error:
error[E0027]: pattern does not mention field `z`
--> src/structures.rs:44:9
|
44 | let ThreeDPoint { x: my_x, y: my_y } = point;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `z`
In JavaScript (ES6), the equivalent destructuring would look like this:
let { x: my_x, y: my_y } = point;