Safety

Rust makes strong guarantees about safety

  • No null or invalid pointers
  • No data races
  • Individual APIs may use the type system to provide their own guarantees. For example String will always be valid utf-8.

To avoid sacrificing performance, Rust provides the unsafe keyword. This enables operations the compiler cannot validate like dereferencing arbitrary pointers, mutating global state, or calling into C code. The Rust typesystem allows writing safe abstractions around these operations.