Skip to main content

SameAs

Trait SameAs 

Source
pub unsafe trait SameAs<T>: IntoAtomic<AtomicType = T> { }
Expand description

Unsafe marker trait for types whose atomic version has the same size and bit representation.

This marker guarantees that a value can be reinterpreted between the non-atomic type and its associated atomic type IntoAtomic::AtomicType by copying the bytes. Note that it does not guarantee equal alignment: on some targets an atomic type has a stricter alignment than its non-atomic counterpart (for example, on 32-bit x86 align_of::<u64>() == 4 but align_of::<AtomicU64>() == 8), which is why the by-reference conversions in IntoAtomic/Atomic check alignment at run time.

It is implemented for all primitive types and for the types of the half crate if the corresponding gate feature is enabled.

§Safety

The implementor must ensure that T has the same size and bit representation as the associated atomic type IntoAtomic::AtomicType.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl SameAs<Atomic<bool>> for bool

Source§

impl SameAs<Atomic<i8>> for i8

Source§

impl SameAs<Atomic<i16>> for i16

Source§

impl SameAs<Atomic<i32>> for i32

Source§

impl SameAs<Atomic<i64>> for i64

Source§

impl SameAs<Atomic<isize>> for isize

Source§

impl SameAs<Atomic<u8>> for u8

Source§

impl SameAs<Atomic<u16>> for u16

Source§

impl SameAs<Atomic<u32>> for u32

Source§

impl SameAs<Atomic<u64>> for u64

Source§

impl SameAs<Atomic<usize>> for usize

Source§

impl SameAs<AtomicBF16> for bf16

Source§

impl SameAs<AtomicF16> for f16

Source§

impl SameAs<AtomicF32> for f32

Source§

impl SameAs<AtomicF64> for f64

Implementors§