News for hackers. Stuff that matters.
Re:Immutable.rs: immutable data structures for Rust by winstonewert on Friday April 06, 2018 @05:16PM (#16777530)
Ok, but I repeat: what is the use case?

Yes, this allows me to do things like add an item to a Vec without modifying it in place, but why would I want to do that? What's the situation where that's helpful?

In other languages I do that, specifically to avoid mutability hell, but that doesn't apply to rust.

EDIT: Thanks to the responders for the great examples!

Re:Immutable.rs: immutable data structures for Rust by masklinn on Friday April 06, 2018 @05:25PM (#16777592)
> Yes, this allows me to do things like add an item to a Vec without modifying it in place, but why would I want to do that? What's the situation where that's helpful?

The context is obviously shared concurrency (hence the library using Arc period), so you can cheaply get a shared immutable structure and manipulate it on your side (without sharing it back), and if necessary share/swap it in at some point, they provide cheap read/copy/update cycles.

With regular collections Rust would preclude misuses but that would still require either deep copies upfront or fairly large exclusive critical sections.

Re:Immutable.rs: immutable data structures for Rust by caconym_ on Friday April 06, 2018 @05:42PM (#16777718)
One example: storing a large text buffer in a persistent data structure (e.g. a rope) can allow you to maintain a space-efficient history of "snapshots" simply by keeping pointers to older versions of the buffer.
Re:Immutable.rs: immutable data structures for Rust by Groxx on Friday April 06, 2018 @06:25PM (#16778036)
No ability to mutate -> no mutable ownership complications. Ever. And that's probably the biggest pain-point for people using Rust.

Not necessary, but can simplify things, by encouraging(/forcing) simpler use of data by default.

Re:Immutable.rs: immutable data structures for Rust by cztomsik on Sunday April 08, 2018 @04:06AM (#16785155)
But you get another pain-point in return - having to replace the whole state at root position, which in turn leads to redux.
Re:Immutable.rs: immutable data structures for Rust by Groxx on Monday April 09, 2018 @05:51PM (#16797306)
That's a pretty normal way to handle immutable-data systems, yes.
Re:Immutable.rs: immutable data structures for Rust by the8472 on Friday April 06, 2018 @05:26PM (#16777595)
It might be useful for RCU data structures in multithreaded code
Re:Immutable.rs: immutable data structures for Rust by cryptonector on Friday April 06, 2018 @06:03PM (#16777870)
Absolutely. This is one very good use case.

Say you have a configuration to read and share with all threads. Each thread can make local changes that will not be visible to the others. The API looks like it's mutating the shared object, but it's actually mutating a copy.

Re:Immutable.rs: immutable data structures for Rust by divs1210 on Sunday April 08, 2018 @03:20PM (#16787779)
maintain history/rewind state to any previous stable time, like git/datomic.