From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 802D1190051 for ; Thu, 6 Mar 2025 12:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741262618; cv=none; b=te5fHe7HpJdUlf1V0gx9h7H8ux5ipVdtX86tx9xzzbyd3wbamwwVIrz6frf5CG2p9ZKZ9k+3MDESiLr2KA5dw4dpDRTd82BZ6xqo3R3p4Zk2phoceIkBiXjrEy6DLPp5631grmeX5SeiVPi02mMMOx/YbIonqmIAsG/jGgXsNdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741262618; c=relaxed/simple; bh=EKN1Aec042lfCLYffY+qogNf06FDM+J+RkLkqOv5eOs=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I9GOJJxRwPqF970C4/EBnbM1v7s+aDdCxLPGjJN6W5kkZMxi0l4fS2lrB132LO3QEixKat6fjit6HDboD1fnsb4gKIKrdqsHQtSWqal5EOWLQBYnoNS1A5cRkFB5DqztN1VAxEcEu6Wu9kugZg2qsyc7zHlMO3D0XD/mX5E6snE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=f9MpQjXO; arc=none smtp.client-ip=185.70.40.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="f9MpQjXO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1741262608; x=1741521808; bh=E9ndBuSbaPlC91uSyBn2kvl1hGQxUxmwYxtPLheGNC4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=f9MpQjXOr3Ph0OkDMzDvotuaC9dgnPDLFsAPUXktv+R9AOUWzzCOi6iaVanU6Nql2 KOz8YRF85N9LyCdS5diahpOo71BWIs9AECTs7icBikKcwmwc2E4iylJ8Aqp+oZy1yi Ie61iMmlhI2otCjyQ0mQ4R3jpuOWtY+IiX4BGmJS3NmInx/7BFcKs+plFfeVXYNZXs AZ+tFPZKaoq0d4SuviQLjbwGys6m/74GmObbwC1PNM6YKYXVm4Zvh23f113N8imb0D N75okFfK5mAH+HgI4jUp1bu5YJjqJ4kviNmrYo1QfiafUxGQdNw2ey9+LYMEMeNUF5 5irvkmqxL3WTA== Date: Thu, 06 Mar 2025 12:03:23 +0000 To: Alice Ryhl From: Oliver Mangold Cc: Andreas Hindborg , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Trevor Gross , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] rust: adding UniqueRefCounted and UniqueRef types Message-ID: In-Reply-To: References: <87ldtj8p2m.fsf@kernel.org> <875xkn8k5z.fsf@kernel.org> Feedback-ID: 31808448:user:proton X-Pm-Message-ID: 9457a7d51cc28f552195fcc7feca8b2f81565b22 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 250306 1131, Alice Ryhl wrote: >=20 > How about this: >=20 > * Rename AlwaysRefCounted to RefCounted. > * Introduce a new AlwaysRefCounted trait with no methods and gate > `From<&T>` on it. It has RefCounted as a sub-trait. > * Introduce an Ownable trait with an Owned type like in [1]. > * Given an Owned where T:RefCounted you can convert from Owned to > ARef. >=20 > And there needs to be a safety requirement on Ownable or > AlwaysRefCounted which requires that a type cannot implement both > traits. Alternatively, if a type implements both, it needs to be safe to > have both Owned and ARef references at the same time, which could > make sense for a type that has one "special" reference and many normal > references. >=20 > If you want conversions ARef to Owned, you should add a new trait > TryIntoOwned that's a super-trait of both RefCounted and Owned and has > the `try` method for the conversion. >=20 > Thoughts? >=20 Yes. Sounds good to me. Basically what I had in mind. Only the naming is different. I will build an implementation like this and post it as v5. I won't change the names of UniqueRef and UniqueRefCounted for now, but more out of laziness than because of having strong feelings about it. I like UniqueRef a bit better as our focus is on pointing out that it is unique. But if you or other prefers Owned I can change it. >=20 > [1]: https://lore.kernel.org/rust-for-linux/20250202-rust-page-v1-1-e3170= d7fe55e@asahilina.net/ Oh, really very similar.