#[no_mangle]
pub extern "C" fn nstd_shared_ptr_get(
    shared_ptr: &NSTDSharedPtr<'_>
) -> NSTDAny
Available on crate feature shared_ptr only.
Expand description

Returns an immutable raw pointer to the shared object.

Parameters:

  • const NSTDSharedPtr *shared_ptr - The shared pointer.

Returns

NSTDAny ptr - A raw pointer to the shared object.

Example

use core::ptr::addr_of;
use nstd_sys::{
    alloc::NSTD_ALLOCATOR,
    shared_ptr::{nstd_shared_ptr_get, nstd_shared_ptr_new},
};

const SIZE: usize = core::mem::size_of::<u128>();

let v = u128::MAX;
unsafe {
    let shared_ptr = nstd_shared_ptr_new(&NSTD_ALLOCATOR, SIZE, addr_of!(v).cast()).unwrap();
    assert!(*nstd_shared_ptr_get(&shared_ptr).cast::<u128>() == v);
}