[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXoX5ixoQYs0cUU5@google.com>
Date: Wed, 28 Jan 2026 14:06:30 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Andreas Hindborg <a.hindborg@...nel.org>
Cc: Will Deacon <will@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>, Mark Rutland <mark.rutland@....com>, Gary Guo <gary@...yguo.net>,
Miguel Ojeda <ojeda@...nel.org>,
"Björn Roy Baron" <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: atomic: add fetch_sub
On Wed, Jan 28, 2026 at 01:47:11PM +0100, Andreas Hindborg wrote:
> Add `Atomic::fetch_sub` with implementation and documentation in line with
> existing `Atomic::fetch_add` implementation.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@...nel.org>
> + /// let x = Atomic::new(42);
> + ///
> + /// assert_eq!(42, x.load(Relaxed));
> + ///
> + /// assert_eq!(30, { x.fetch_sub(12, Acquire); x.load(Relaxed) });
These asserts are a bit confusing to read. After all, the fetch_sub call
also returns a value, so how about this?
let x = Atomic::new(42);
assert_eq!(42, x.load(Relaxed));
assert_eq!(42, x.fetch_sub(12, Acquire));
assert_eq!(30, x.load(Relaxed));
Otherwise LGTM.
Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
Alice
Powered by blists - more mailing lists