Skip to Content
Idiomatic Rust
book

Idiomatic Rust

by Brenden Matthews
September 2024
Intermediate to advanced
256 pages
6h 40m
English
Manning Publications
Content preview from Idiomatic Rust

9 Immutability

This chapter covers

  • Understanding the benefits of immutability
  • Thinking in terms of immutable data and how it works in Rust
  • Using traits to make nearly anything immutable
  • Exploring crates that provide immutable data structures

Immutability is a powerful concept that can help everyone build better software. Immutability as it relates to writing software is the idea that after a value has been declared and assigned, it cannot be modified (or mutated). Contrast this concept with mutability, in which a value can be altered after it has been declared. In other words, values that can be changed are mutable, and values that are never changed are immutable.

Immutability is an important design pattern—and one of the most underloved ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rust in Action

Rust in Action

Tim McNamara
Effective Rust

Effective Rust

David Drysdale
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9781633437463Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link