Rust Raw Pointers


  • let raw_ptr = &pointee as *const type // create constant raw pointer to some data
  • let raw_mut_ptr = &mut pointee as *mut type // create mutable raw pointer to some mutable data
  • let deref = *raw_ptr // dereference a raw pointer (requires unsafe block)


  • Raw pointers are not guaranteed to point to a valid memory address and as such, careless usage may lead to unexpected (and probably fatal) errors.
  • Any normal Rust reference (eg. &my_object where the type of my_object is T) will coerce to *const T. Similarly, mutable references coerce to *mut T.
  • Raw pointers do not move ownership (in contrast to Box values that)