AsPtr

Trait AsPtr 

Source
pub trait AsPtr: Atomic {
    // Required method
    fn as_ptr(&self) -> *mut Self::Type;
}
Expand description

Returns a mutable pointer to the underlying type.

Required Methods§

Source

fn as_ptr(&self) -> *mut Self::Type

Returns a mutable pointer to the underlying type.

§Examples
use std::sync::atomic::AtomicBool;
use atomic_traits::Atomic;

extern "C" {
    fn my_atomic_op(arg: *mut bool);
}

let mut atomic = AtomicBool::new(true);
unsafe {
    my_atomic_op(Atomic::as_ptr(&atomic));
}

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 AsPtr for AtomicBool

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicI8

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicI16

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicI32

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicI64

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicIsize

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicU8

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicU16

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicU32

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicU64

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl AsPtr for AtomicUsize

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Source§

impl<T> AsPtr for AtomicPtr<T>

Available on crate features atomic_as_ptr or since_1_70_0 only.
Source§

fn as_ptr(&self) -> *mut Self::Type

Implementors§