liveBook · Manning

Safety

As explained in Rust in Action: Systems programming concepts and techniques

Software safety is the property of software behavior being constrained to avoid invalid, harmful, or erroneous outcomes.

Software safety constrains behavior so programs avoid invalid, harmful, or erroneous outcomes. In Rust, safety centers on preventing invalid data access at compile time while preserving systems-level performance. section 1.6

Rust connects safety with several practical goals:

  • Memory safety: Rust guarantees memory-safe programs and eliminates invalid-data-access bugs without runtime costs. section 1.6
  • Concurrency safety: Rust prevents whole classes of errors associated with concurrent and parallel programming. section 1.12
  • Operational safety: Rust adds protection to resource-constrained devices without imposing runtime costs, which matters when firmware updates are infrequent. section 1.10.4
  • Zero-cost safety: compile-time checks and safety guarantees are preferred when they avoid slowing the running program. section 1.12 section 1.6.3

Choosing controlled representations

Rust can represent an integer directly, on the heap, through reference counting, or behind shared synchronization. These choices expose different semantics and runtime characteristics while retaining safety as the first priority. section 1.6.3

Figure 1.1 Rust provides both safety and control. Other languages have tended to trade one against the other.

Use the comparison figure to see safety and control treated as compatible goals rather than opposing trade-offs. section 1.6

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Explains compile-time memory safety, concurrency errors, and zero-cost checks, but does not detail the underlying checking mechanisms.
Examples
Uses invalid data access, insecure IoT input parsing, infrequently updated firmware, and multiple integer representations.
What you can do after
Evaluate how Rust’s compile-time guarantees protect memory and concurrency without requiring runtime safety costs.
How it connects
Connects safety with memory safety, concurrency, compile-time checks, zero-cost abstractions, control, and systems programming.

Also explained in

Compare how 8 books explain safety →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.