Trait atomic_traits::fetch::And
source · pub trait And {
type Type;
// Required method
fn fetch_and(&self, val: Self::Type, order: Ordering) -> Self::Type;
}
Expand description
Bitwise “and” with the current value.
Required Associated Types§
Required Methods§
sourcefn fetch_and(&self, val: Self::Type, order: Ordering) -> Self::Type
fn fetch_and(&self, val: Self::Type, order: Ordering) -> Self::Type
Bitwise “and” with the current value.
Performs a bitwise “and” 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::And::fetch_and(&foo, 0b110011, Ordering::SeqCst), 0b101101);
assert_eq!(Atomic::load(&foo, Ordering::SeqCst), 0b100001);