pub trait Min {
type Type;
// Required method
fn fetch_min(&self, val: Self::Type, order: Ordering) -> Self::Type;
}Expand description
Minimum with the current value.
Required Associated Types§
Required Methods§
Sourcefn fetch_min(&self, val: Self::Type, order: Ordering) -> Self::Type
fn fetch_min(&self, val: Self::Type, order: Ordering) -> Self::Type
Minimum with the current value.
Finds the minimum of 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(23);
assert_eq!(fetch::Min::fetch_min(&foo, 42, Ordering::Relaxed), 23);
assert_eq!(Atomic::load(&foo, Ordering::Relaxed), 23);
assert_eq!(fetch::Min::fetch_min(&foo, 22, Ordering::Relaxed), 23);
assert_eq!(Atomic::load(&foo, Ordering::Relaxed), 22);