Destructuring private fields

I have a Struct which has both pub fields and private fields. Can rust only destructuring the pub fields and ignore the private ones?

MyStruct {
pub x: f32,
y: f32,
pub z: f32
}

let foo = MyStruct { x: 0.3, y: 0.4, z: 0.5 };
let MyStruct { my_x, .., my_z } = foo;

I had to make some changes to get things to compile, but yes, it can.

1 Like

Thanks a lot, it works.