nstd_core_ptr_get

Function nstd_core_ptr_get 

Source
#[unsafe(no_mangle)]
pub const extern "C" fn nstd_core_ptr_get(ptr: &NSTDPtr) -> NSTDAny
Available on crate feature core only.
Expand description

Returns a raw immutable pointer to the object pointed to by ptr.

§Parameters:

  • const NSTDPtr *ptr - The higher level pointer.

§Returns

NSTDAny raw - A raw pointer to the object.

§Examples

use core::ptr::addr_of;
use nstd_sys::core::ptr::{nstd_core_ptr_get, nstd_core_ptr_new};

unsafe {
    const SIZE: usize = core::mem::size_of::<u32>();
    const ALIGN: usize = core::mem::align_of::<u32>();
    let x = 45u32;
    let ptr = nstd_core_ptr_new(addr_of!(x).cast(), SIZE, ALIGN).unwrap();
    assert!(*nstd_core_ptr_get(&ptr).cast::<u32>() == x);
}