Unsafe Rust
Raw pointers
Addresses without borrow tracking: what they are, and why reading through one needs unsafe
What a raw pointer is
A raw pointer is just an address. Unlike a reference it can be null, dangling or aliased, so creating one is safe but reading or writing through it needs unsafe
Writing through a pointer
1fn main() {2 let mut x = 5;3 let p = &raw mut x;45 unsafe {6 *p += 1;7 }8 println!("{x}");9}p holds the address of x. Writing through it changes x in place, with no borrow tracking