rust/zeroable: Implement Zeroable with const_zero macro
authorZhao Liu <zhao1.liu@intel.com>
Thu, 23 Jan 2025 18:07:28 +0000 (19:07 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 28 Jan 2025 16:58:09 +0000 (17:58 +0100)
commitaaf3778baaa6408460ec6e6636babbdf0b92c101
tree96966d107eb2c01eb0ba957d6c47f098c6b641dc
parentaf7edb1d326de0af565b48c663163c7e5050e03c
rust/zeroable: Implement Zeroable with const_zero macro

The `const_zero` crate provides a nice macro to zero type-specific
constants, which doesn't need to enumerates the fields one by one.

Introduce the `const_zero` macro to QEMU (along with its documentation), and
use it to simplify the implementation of `Zeroable` trait.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250123163143.679841-1-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/qemu-api/src/zeroable.rs