primitive-type

Rust pointer: represent raw memory addresses

A raw pointer can represent a location without the validity guarantees of a Rust reference. Creating and comparing raw pointers is generally safe; dereferencing requires unsafe code and proof of the relevant validity conditions. Expected output (not executed): true Why: Both pointer expressions refer to the same local value. Common mistake: A null check alone cannot establish that a pointer refers to a live, aligned and initialized value.

Formal Syntax & Structure

rust syntaxrust
*const T; *mut T

Working Example

Example Snippetrust
fn main() {    let number = 11_u32;    let ptr: *const u32 = &raw const number;    println!("{}", ptr == &raw const number);}
Rust Reference