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};
fn make_atomic<T: AtomicPrimitive>(val: T) -> T::Atomic {
T::Atomic::new(val)
}Required Associated Types§
Sourcetype Atomic: PrimitiveAtomic<Value = Self>
type Atomic: PrimitiveAtomic<Value = Self>
The atomic type corresponding to this primitive type.
Note that the bound on Value is not imposed in the unstable
core::sync::atomic::AtomicPrimitive trait, but it is useful
to round-trip between the primitive and atomic types.
Provided Methods§
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.