diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2024-10-18 10:51:10 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-11-05 14:18:16 +0100 |
commit | 6e50bde1e1c8edc70145fb87b21b0d0843250600 (patch) | |
tree | 52f98f9fcb5d98a06d7b92d96a34f614a3ede59c /rust/qemu-api/src/lib.rs | |
parent | c92c447ff04ca6a5b80da2930d87637b34713b8c (diff) | |
download | qemu-6e50bde1e1c8edc70145fb87b21b0d0843250600.zip qemu-6e50bde1e1c8edc70145fb87b21b0d0843250600.tar.gz qemu-6e50bde1e1c8edc70145fb87b21b0d0843250600.tar.bz2 |
rust: provide safe wrapper for MaybeUninit::zeroed()
MaybeUninit::zeroed() is handy, but it introduces unsafe (and has a
pretty heavy syntax in general). Introduce a trait that provides the
same functionality while staying within safe Rust.
In addition, MaybeUninit::zeroed() is not available as a "const"
function until Rust 1.75.0, so this also prepares for having handwritten
implementations of the trait until we can assume that version.
Reviewed-by: Junjie Mao <junjie.mao@hotmail.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api/src/lib.rs')
-rw-r--r-- | rust/qemu-api/src/lib.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 6bc6807..e94a15b 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -29,6 +29,7 @@ unsafe impl Sync for bindings::VMStateDescription {} pub mod definitions; pub mod device_class; +pub mod zeroable; use std::alloc::{GlobalAlloc, Layout}; |