mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
1944caa8e8
commit
52a7f2deb4
1 changed files with 2 additions and 2 deletions
|
@ -1190,8 +1190,8 @@ pub fn uninit<T, E>() -> impl Init<MaybeUninit<T>, E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: Every type can be initialized by-value.
|
// SAFETY: Every type can be initialized by-value.
|
||||||
unsafe impl<T> Init<T> for T {
|
unsafe impl<T, E> Init<T, E> for T {
|
||||||
unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible> {
|
unsafe fn __init(self, slot: *mut T) -> Result<(), E> {
|
||||||
unsafe { slot.write(self) };
|
unsafe { slot.write(self) };
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue