Persistent Data Structure Support

There's crates like im which provide structures like these. As the im documentation says, though:

While immutable data structures can be a game changer for other programming languages, the most obvious benefit - avoiding the accidental mutation of data - is already handled so well by Rust's type system that it's just not something a Rust programmer needs to worry about even when using data structures that would send a conscientious Clojure programmer into a panic.

Rust uses mutable data structures by default because they're a good general fit - they're often more efficient, and because of Rust's rules they provide much of the safety and utility gotten from immutable structures in other languages. However, there are totally cases where immutable structures are better in Rust, it's just down to a case-by-case basis.

10 Likes