Re: [PATCH v5 03/10] rust: sync: atomic: Add ordering annotation types

Boqun Feng
2025-06-27T14:44:55Z

On Fri, Jun 27, 2025 at 07:34:46AM -0700, Boqun Feng wrote:
> On Thu, Jun 26, 2025 at 02:36:50PM +0200, Andreas Hindborg wrote:
> [...]
> > > +/// The trait bound for annotating operations that should support all orderings.
> > > +pub trait All: internal::OrderingUnit {}
> >
> > I think I would prefer `Any` rather than `All` here. Because it is "any
> > of", not "all of them at once".
> >
>
> Good idea! Changed. Thanks!
>

And I realized I can unify `Any` with `OrderingUnit`, here is the what I
have now:

mod internal {
/// Sealed trait, can be only implemented inside atomic mod.
pub trait Sealed {}

impl Sealed for super::Relaxed {}
impl Sealed for super::Acquire {}
impl Sealed for super::Release {}
impl Sealed for super::Full {}
}

/// The trait bound for annotating operations that support any ordering.
pub trait Any: internal::Sealed {
/// Describes the exact memory ordering.
const TYPE: OrderingType;
}

impl Any for Relaxed {
const TYPE: OrderingType = OrderingType::Relaxed;
}

impl Any for Acquire {
const TYPE: OrderingType = OrderingType::Acquire;
}

impl Any for Release {
const TYPE: OrderingType = OrderingType::Release;
}

impl Any for Full {
const TYPE: OrderingType = OrderingType::Full;
}

Better than what I had before, thanks!

Regards,
Boqun