keyword

Rust raw: create a raw pointer without creating a reference

The contextual keyword raw forms a raw borrow expression. It creates a raw pointer directly rather than first making a Rust reference. Creating a pointer does not establish that dereferencing it later is valid. Expected output (not executed): false Why: The pointer was derived from a live local value and is not null. Common mistake: A non-null raw pointer is not necessarily safe to dereference. Check lifetime, alignment, initialization and access permissions.

Formal Syntax & Structure

rust syntaxrust
&raw const place; &raw mut place

Working Example

Example Snippetrust
fn main() {    let value = 5_u32;    let ptr = &raw const value;    println!("{}", ptr.is_null());}
Rust Reference