expression
Create raw pointers with raw borrow syntax
The raw borrow operators produce pointers without creating an intermediate reference to the place. The mut form requires a writable place. In this example the local is live and initialized; the pointer is used alone for the duration of the write. Expected stdout (not executed): 18 Common mistake: Assuming raw borrow syntax makes access to any place safe.
Formal Syntax & Structure
rust syntaxrust
&raw const place / &raw mut placeWorking Example
Example Snippetrust
#![deny(unsafe_op_in_unsafe_fn)]fn main() { let mut value = 12_i32; let p = &raw mut value; // SAFETY: local value is aligned and initialized; no competing access. unsafe { *p = 18; } println!("{value}");}