Skip to content

Commit abf56d8

Browse files
hoshinolinajannau
authored andcommitted
rust: types: Add Opaque::zeroed()
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent 94a7312 commit abf56d8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

rust/kernel/types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ impl<T> Opaque<T> {
326326
}
327327
}
328328

329+
/// Creates a zeroed value.
330+
pub fn zeroed() -> Self {
331+
Self {
332+
value: UnsafeCell::new(MaybeUninit::zeroed()),
333+
_pin: PhantomPinned,
334+
}
335+
}
336+
329337
/// Create an opaque pin-initializer from the given pin-initializer.
330338
pub fn pin_init(slot: impl PinInit<T>) -> impl PinInit<Self> {
331339
Self::ffi_init(|ptr: *mut T| {

0 commit comments

Comments
 (0)