mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 12:23:53 -06:00
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>
This commit is contained in:
parent
c92c447ff0
commit
6e50bde1e1
6 changed files with 35 additions and 10 deletions
|
@ -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};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue