expression

Rust Create raw pointers without references

Raw borrowing produces a pointer without creating a reference. It is useful in low-level code when reference validity rules cannot be assumed. Creating these pointers is safe here; accessing the pointee through one requires separate safety reasoning. Expected output (not executed): true Why: Both raw pointers address the same local integer, and no dereferencing is performed. Common mistake: A raw pointer does not prove that the allocation remains alive or that dereferencing is valid.

Formal Syntax & Structure

rust syntaxrust
&raw const place; &raw mut place

Working Example

Example Snippetrust
fn main() {    let mut count = 5;    let p = &raw const count;    let q = &raw mut count;    println!("{}", p == q as *const i32);}
Rust Reference