lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D93UIO9E7HBY.3USCKDO42JP5C@nvidia.com>
Date: Fri, 11 Apr 2025 22:32:32 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Benno Lossin" <benno.lossin@...ton.me>, "Danilo Krummrich"
 <dakr@...nel.org>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
 <alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
 <gary@...yguo.net>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, "Andreas Hindborg" <a.hindborg@...nel.org>,
 "Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>
Cc: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] rust: alloc: allow coercion from `Box<T>` to
 `Box<dyn U>` if T implements U

On Fri Apr 11, 2025 at 9:43 PM JST, Benno Lossin wrote:
> On Fri Apr 11, 2025 at 2:07 PM CEST, Alexandre Courbot wrote:
>> This enables the creation of trait objects backed by a Box, similarly to
>> what can be done with the standard library.
>>
>> Suggested-by: Benno Lossin <benno.lossin@...ton.me>
>> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
>
> Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
>
>> ---
>> From this discussion on Zulip [1].
>>
>> Heavily inspired from the similar feature on `Arc`.
>>
>> [1] https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/Trait.20objects.3F/with/510689662
>> ---
>> Changes in v2:
>> - Use where clauses to improve readability.
>> - Fix build with rustc 1.78.
>> - Link to v1: https://lore.kernel.org/r/20250408-box_trait_objs-v1-1-58d8e78b0fb2@nvidia.com
>> ---
>>  rust/kernel/alloc/kbox.rs | 30 +++++++++++++++++++++++++++++-
>>  1 file changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs
>> index b77d32f3a58bab5ec73c612bdaaba0d79bfdff65..b9a905cd4bd285782b0db284b6771aec03e0c10b 100644
>> --- a/rust/kernel/alloc/kbox.rs
>> +++ b/rust/kernel/alloc/kbox.rs
>> @@ -32,6 +32,8 @@
>>  ///
>>  /// When dropping a [`Box`], the value is also dropped and the heap memory is automatically freed.
>>  ///
>> +/// [`Box`]es can also be used to store trait objects by coercing their type.
>> +///
>>  /// # Examples
>
> I agree with Miguel, you could move the added line above down here and
> also provide a simple example.

Oops, I completely forgot to address Miguel's comment, sorry about that.
Will send a new version.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ