From: Andreas Hindborg <a.hindborg@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: atomic: add fetch_sub
Date: Wed, 28 Jan 2026 15:16:07 +0100 [thread overview]
Message-ID: <87ms1xstzs.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <aXoX5ixoQYs0cUU5@google.com>
"Alice Ryhl" <aliceryhl@google.com> writes:
> 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@kernel.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));
We can do that. I basically copied the docs from add. Should I change
those as well?
Best regards,
Andreas Hindborg
next prev parent reply other threads:[~2026-01-28 14:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 12:47 Andreas Hindborg
2026-01-28 14:06 ` Alice Ryhl
2026-01-28 14:16 ` Andreas Hindborg [this message]
2026-01-28 14:24 ` Gary Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ms1xstzs.fsf@t14s.mail-host-address-is-not-set \
--to=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mark.rutland@arm.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®