Skip to main content

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);

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Sub for Atomic<i8>

Source§

type Type = i8

Source§

fn fetch_sub( &self, val: <Atomic<i8> as Sub>::Type, order: Ordering, ) -> <Atomic<i8> as Sub>::Type

Source§

impl Sub for Atomic<i16>

Source§

type Type = i16

Source§

fn fetch_sub( &self, val: <Atomic<i16> as Sub>::Type, order: Ordering, ) -> <Atomic<i16> as Sub>::Type

Source§

impl Sub for Atomic<i32>

Source§

type Type = i32

Source§

fn fetch_sub( &self, val: <Atomic<i32> as Sub>::Type, order: Ordering, ) -> <Atomic<i32> as Sub>::Type

Source§

impl Sub for Atomic<i64>

Source§

type Type = i64

Source§

fn fetch_sub( &self, val: <Atomic<i64> as Sub>::Type, order: Ordering, ) -> <Atomic<i64> as Sub>::Type

Source§

impl Sub for Atomic<isize>

Source§

type Type = isize

Source§

fn fetch_sub( &self, val: <Atomic<isize> as Sub>::Type, order: Ordering, ) -> <Atomic<isize> as Sub>::Type

Source§

impl Sub for Atomic<u8>

Source§

type Type = u8

Source§

fn fetch_sub( &self, val: <Atomic<u8> as Sub>::Type, order: Ordering, ) -> <Atomic<u8> as Sub>::Type

Source§

impl Sub for Atomic<u16>

Source§

type Type = u16

Source§

fn fetch_sub( &self, val: <Atomic<u16> as Sub>::Type, order: Ordering, ) -> <Atomic<u16> as Sub>::Type

Source§

impl Sub for Atomic<u32>

Source§

type Type = u32

Source§

fn fetch_sub( &self, val: <Atomic<u32> as Sub>::Type, order: Ordering, ) -> <Atomic<u32> as Sub>::Type

Source§

impl Sub for Atomic<u64>

Source§

type Type = u64

Source§

fn fetch_sub( &self, val: <Atomic<u64> as Sub>::Type, order: Ordering, ) -> <Atomic<u64> as Sub>::Type

Source§

impl Sub for Atomic<usize>

Source§

type Type = usize

Source§

fn fetch_sub( &self, val: <Atomic<usize> as Sub>::Type, order: Ordering, ) -> <Atomic<usize> as Sub>::Type

Implementors§

Source§

impl<T> Sub for AtomicNumber<T>
where T: PrimitiveAtomicInteger + FromPrimitive,

Source§

type Type = T