Re: [PATCH v4 4/5] rust: types: ForeignOwnable: Add type Target
From: Alice Ryhl
Date: Tue Jul 01 2025 - 07:55:30 EST
On Thu, Jun 26, 2025 at 10:01 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> ForeignOwnable::Target defines the payload data of a ForeignOwnable. For
> Arc<T> for instance, ForeignOwnable::Target would just be T.
>
> This is useful for cases where a trait bound is required on the target
> type of the ForeignOwnable. For instance:
>
> fn example<P>(data: P)
> where
> P: ForeignOwnable,
> P::Target: MyTrait,
> {}
>
> Suggested-by: Benno Lossin <lossin@xxxxxxxxxx>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
I am skeptical about this patch. I think that most of the time, you
should just place the trait bound on `P` instead of having a Target
type like this.
Alice