Rust Raw Pointers Initialising a raw pointer to null


Example

Unlike normal Rust references, raw pointers are allowed to take null values.

use std::ptr;

// Create a const NULL pointer
let null_ptr: *const u16 = ptr::null();

// Create a mutable NULL pointer
let mut_null_ptr: *mut u16 = ptr::null_mut();