std-module

Rust std::ptr module

The pointer module exposes operations for working directly with memory. A raw pointer need not identify a usable object. Establish the requirements of a particular operation before accessing storage. This example only constructs and tests a sentinel, so no unsafe access is needed. Expected stdout (not executed): absent: true Common mistake: Treating a non-null test as a complete safety check.

Formal Syntax & Structure

rust syntaxrust
use std::ptr;

Working Example

Example Snippetrust
#![deny(unsafe_op_in_unsafe_fn)]fn main() {    use std::ptr;    let absent = ptr::null::<i32>();    println!("absent: {}", absent.is_null());}
Rust Reference