Skip to content

Commit 1ecf5d8

Browse files
y86-devherrnst
authored andcommitted
rust: init: broaden the blanket impl of Init
This makes it possible to use `T` as a `impl Init<T, E>` for every error type `E` instead of just `Infallible`. Signed-off-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 194f516 commit 1ecf5d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/kernel/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,8 @@ pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> {
11901190
}
11911191

11921192
// SAFETY: Every type can be initialized by-value.
1193-
unsafe impl<T> Init<T> for T {
1194-
unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible> {
1193+
unsafe impl<T, E> Init<T, E> for T {
1194+
unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
11951195
unsafe { slot.write(self) };
11961196
Ok(())
11971197
}

0 commit comments

Comments
 (0)