Skip to main content

AtomicPrimitive

Trait AtomicPrimitive 

Source
pub trait AtomicPrimitive:
    Sized
    + Copy
    + Send
    + Sync {
    type Atomic: PrimitiveAtomic<Value = Self>;

    // Provided method
    fn to_atomic(self) -> Self::Atomic { ... }
}
Expand description

Maps a non-atomic primitive type to its corresponding atomic type.

This mirrors the unstable core::sync::atomic::AtomicPrimitive trait. Once that trait is stabilized, this can be deprecated in favor of the std version.

§Examples

use atomic_primitive::{AtomicPrimitive, PrimitiveAtomic};
use core::sync::atomic::Ordering;

fn make_atomic<T: AtomicPrimitive>(val: T) -> T::Atomic {
    T::Atomic::new(val)
}

Required Associated Types§

Source

type Atomic: PrimitiveAtomic<Value = Self>

The atomic type corresponding to this primitive type.

Provided Methods§

Source

fn to_atomic(self) -> Self::Atomic

Converts this value to its atomic counterpart.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AtomicPrimitive for bool

Source§

impl AtomicPrimitive for i8

Source§

impl AtomicPrimitive for i16

Source§

impl AtomicPrimitive for i32

Source§

impl AtomicPrimitive for i64

Source§

impl AtomicPrimitive for isize

Source§

impl AtomicPrimitive for u8

Source§

impl AtomicPrimitive for u16

Source§

impl AtomicPrimitive for u32

Source§

impl AtomicPrimitive for u64

Source§

impl AtomicPrimitive for usize

Implementors§