* [PATCH] rust: init: broaden the blanket impl of `Init`
@ 2023-04-13 10:02 Benno Lossin
2023-04-13 11:43 ` Martin Rodriguez Reboredo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Benno Lossin @ 2023-04-13 10:02 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron
Cc: rust-for-linux, linux-kernel, patches, Benno Lossin
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>
---
@Miguel: you can squash this patch into 90e53c5e70a69 or put it on top of
rust-next.
rust/kernel/init.rs | 4 ++--
1 file 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(())
}
base-commit: 1944caa8e8dcb2d93d99d8364719ad8d07aa163f
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: init: broaden the blanket impl of `Init`
2023-04-13 10:02 [PATCH] rust: init: broaden the blanket impl of `Init` Benno Lossin
@ 2023-04-13 11:43 ` Martin Rodriguez Reboredo
2023-04-13 12:33 ` Gary Guo
2023-04-21 22:46 ` Miguel Ojeda
2 siblings, 0 replies; 4+ messages in thread
From: Martin Rodriguez Reboredo @ 2023-04-13 11:43 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
Boqun Feng, Gary Guo, Björn Roy Baron
Cc: rust-for-linux, linux-kernel, patches
On 4/13/23 07:02, Benno Lossin wrote:
> 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>
> ---
>
> @Miguel: you can squash this patch into 90e53c5e70a69 or put it on top of
> rust-next.
>
> rust/kernel/init.rs | 4 ++--
> 1 file 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(())
> }
>
> base-commit: 1944caa8e8dcb2d93d99d8364719ad8d07aa163f
> --
> 2.39.2
>
>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: init: broaden the blanket impl of `Init`
2023-04-13 10:02 [PATCH] rust: init: broaden the blanket impl of `Init` Benno Lossin
2023-04-13 11:43 ` Martin Rodriguez Reboredo
@ 2023-04-13 12:33 ` Gary Guo
2023-04-21 22:46 ` Miguel Ojeda
2 siblings, 0 replies; 4+ messages in thread
From: Gary Guo @ 2023-04-13 12:33 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Björn Roy Baron, rust-for-linux, linux-kernel, patches
On Thu, 13 Apr 2023 10:02:17 +0000
Benno Lossin <benno.lossin@proton.me> wrote:
> 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>
> ---
>
> @Miguel: you can squash this patch into 90e53c5e70a69 or put it on top of
> rust-next.
>
> rust/kernel/init.rs | 4 ++--
> 1 file 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(())
> }
>
> base-commit: 1944caa8e8dcb2d93d99d8364719ad8d07aa163f
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: init: broaden the blanket impl of `Init`
2023-04-13 10:02 [PATCH] rust: init: broaden the blanket impl of `Init` Benno Lossin
2023-04-13 11:43 ` Martin Rodriguez Reboredo
2023-04-13 12:33 ` Gary Guo
@ 2023-04-21 22:46 ` Miguel Ojeda
2 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2023-04-21 22:46 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron, rust-for-linux, linux-kernel,
patches
On Thu, Apr 13, 2023 at 12:02 PM Benno Lossin <benno.lossin@proton.me> wrote:
>
> This makes it possible to use `T` as a `impl Init<T, E>` for every error
> type `E` instead of just `Infallible`.
Applied to `rust-next`. Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-21 22:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 10:02 [PATCH] rust: init: broaden the blanket impl of `Init` Benno Lossin
2023-04-13 11:43 ` Martin Rodriguez Reboredo
2023-04-13 12:33 ` Gary Guo
2023-04-21 22:46 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).