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] [day] [month] [year] [list]
Message-ID: <CAH5fLghbb8zMsJ7y+it3U3pE0xdXfOxGX3kfLQf0kJp=4xZWgA@mail.gmail.com>
Date: Thu, 6 Mar 2025 13:08:47 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Oliver Mangold <oliver.mangold@...me>
Cc: Andreas Hindborg <a.hindborg@...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>, 
	Benno Lossin <benno.lossin@...ton.me>, Trevor Gross <tmgross@...ch.edu>, 
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] rust: adding UniqueRefCounted and UniqueRef types

On Thu, Mar 6, 2025 at 1:03 PM Oliver Mangold <oliver.mangold@...me> wrote:
>
> On 250306 1131, Alice Ryhl wrote:
> >
> > How about this:
> >
> > * 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<T> where T:RefCounted you can convert from Owned<T> to
> >   ARef<T>.
> >
> > 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<T> and ARef<T> references at the same time, which could
> > make sense for a type that has one "special" reference and many normal
> > references.
> >
> > If you want conversions ARef<T> to Owned<T>, 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.
> >
> > Thoughts?
> >
> 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.

Advantage of the Owned naming is that it also makes sense for types
that *only* support Owned pointers. The UniqueRef name kind of assumes
that it's refcounted, but the design I proposed does not have that
limitation.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ