Skip to content

Commit 9324f86

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

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
@@ -230,6 +230,14 @@ impl<T> Opaque<T> {
230230
}
231231
}
232232

233+
/// Creates a zeroed value.
234+
pub fn zeroed() -> Self {
235+
Self {
236+
value: UnsafeCell::new(MaybeUninit::zeroed()),
237+
_pin: PhantomPinned,
238+
}
239+
}
240+
233241
/// Creates a pin-initializer from the given initializer closure.
234242
///
235243
/// The returned initializer calls the given closure with the pointer to the inner `T` of this

0 commit comments

Comments
 (0)