diff options
author | Benno Lossin <benno.lossin@proton.me> | 2023-04-13 10:02:17 +0000 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2023-04-21 00:35:26 +0200 |
commit | 52a7f2deb4be8706bcbd16bba1d70eb2b5735d19 (patch) | |
tree | 4850d2e3dcaecbb44161d1246c70a753b23925d1 /rust | |
parent | 1944caa8e8dcb2d93d99d8364719ad8d07aa163f (diff) |
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 <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Link: https://lore.kernel.org/r/20230413100157.740697-1-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust')
-rw-r--r-- | rust/kernel/init.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index a1298c8bbda0..4ebfb08dab11 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -1190,8 +1190,8 @@ pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> { } // SAFETY: Every type can be initialized by-value. -unsafe impl<T> Init<T> for T { - unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible> { +unsafe impl<T, E> Init<T, E> for T { + unsafe fn __init(self, slot: *mut T) -> Result<(), E> { unsafe { slot.write(self) }; Ok(()) } |