Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: sync: atomic: Update documentation for `fetch_add()`

The documentation for `fetch_add()` does not indicate that the original
value is returned by `fetch_add()`. Update the documentation so this is
clear.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Boqun Feng <boqun@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260220-atomic-sub-v3-2-e63cbed1d2aa@kernel.org
Link: https://patch.msgid.link/20260303201701.12204-13-boqun@kernel.org

authored by

Andreas Hindborg and committed by
Peter Zijlstra
0b864375 c49cf341

+4 -6
+4 -6
rust/kernel/sync/atomic.rs
··· 545 545 /// use kernel::sync::atomic::{Atomic, Acquire, Full, Relaxed}; 546 546 /// 547 547 /// let x = Atomic::new(42); 548 - /// 549 548 /// assert_eq!(42, x.load(Relaxed)); 550 - /// 551 - /// assert_eq!(54, { x.fetch_add(12, Acquire); x.load(Relaxed) }); 549 + /// assert_eq!(42, x.fetch_add(12, Acquire)); 550 + /// assert_eq!(54, x.load(Relaxed)); 552 551 /// 553 552 /// let x = Atomic::new(42); 554 - /// 555 553 /// assert_eq!(42, x.load(Relaxed)); 556 - /// 557 - /// assert_eq!(54, { x.fetch_add(12, Full); x.load(Relaxed) } ); 554 + /// assert_eq!(42, x.fetch_add(12, Full)); 555 + /// assert_eq!(54, x.load(Relaxed)); 558 556 /// ``` 559 557 #[inline(always)] 560 558 pub fn fetch_add<Rhs, Ordering: ordering::Ordering>(&self, v: Rhs, _: Ordering) -> T