A coworker sent me this interesting snippet from the Windows Driver Kit (WDK) Rust samples.
let [()] = [unsafe {
macros::call_unsafe_wdf_function_binding!(
WdfDeviceInitSetPnpPowerEventCallbacks,
device_init,
&mut pnp_power_callbacks
)
}];
I can understand why one might want to do let () = to assert at compile time that the unsafe block returns a unit type. I cannot, however, understand why these samples would wrap the result in an array expression, just to immediately unpack it. This is done with some frequency in the examples, leading me to believe that there must be some reason for it. However, the code seems to compile without doing this, and the doc examples don't do it either.
Is there some reason why this might be necessary? My shot in the dark is that the array expression might provide some kind of compile-time safety guarantee w/ the unsafe, but I don't really know that for sure.