pub trait Xor {
type Type;
// Required method
fn fetch_xor(&self, val: Self::Type, order: Ordering) -> Self::Type;
}Expand description
Bitwise “xor” with the current value.
Required Associated Types§
Required Methods§
Sourcefn fetch_xor(&self, val: Self::Type, order: Ordering) -> Self::Type
fn fetch_xor(&self, val: Self::Type, order: Ordering) -> Self::Type
Bitwise “xor” with the current value.
Performs a bitwise “xor” operation on the current value and the argument val,
and sets the new value to the result.
Returns the previous value.
§Examples
use std::sync::atomic::{AtomicU8, Ordering};
use atomic_traits::{Atomic, fetch};
let foo = AtomicU8::new(0b101101);
assert_eq!(fetch::Xor::fetch_xor(&foo, 0b110011, Ordering::SeqCst), 0b101101);
assert_eq!(Atomic::load(&foo, Ordering::SeqCst), 0b011110);