Sub

Trait Sub 

Source
pub trait Sub {
    type Type;

    // Required method
    fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type;
}
Expand description

Subtracts from the current value, returning the previous value.

Required Associated Types§

Source

type Type

The underlying type

Required Methods§

Source

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Subtracts from the current value, returning the previous value.

This operation wraps around on overflow.

§Examples
use std::sync::atomic::{AtomicU8, Ordering};
use atomic_traits::{Atomic, fetch};

let foo = AtomicU8::new(20);
assert_eq!(fetch::Sub::fetch_sub(&foo, 10, Ordering::SeqCst), 20);
assert_eq!(Atomic::load(&foo, Ordering::SeqCst), 10);

Implementations on Foreign Types§

Source§

impl Sub for AtomicI8

Source§

type Type = i8

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicI16

Source§

type Type = i16

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicI32

Source§

type Type = i32

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicI64

Source§

type Type = i64

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicIsize

Source§

type Type = isize

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicU8

Source§

type Type = u8

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicU16

Source§

type Type = u16

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicU32

Source§

type Type = u32

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicU64

Source§

type Type = u64

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Source§

impl Sub for AtomicUsize

Source§

type Type = usize

Source§

fn fetch_sub(&self, val: Self::Type, order: Ordering) -> Self::Type

Implementors§