> How about having container types in which accessors swap the original with
> none?

- For bigger data structures, you'd still pay the cost of several copies.

- You're destroying your original data structure, which is usually not
what you want and often not even possible (when it's part of a bigger
data structure).

- You could of course make those data structures mutable and swap in
dummy values. This will propagate mutability all over the place and
lose all of the simplicity and safety benefits that made use make
immutable the default in the first place.

- For larger data structures (say, maps), moving things out breaks
invariants. You could code around this by making the data structure
more complex, and requiring it to be used in a certain way. This would
be a complexity tax we're putting on all data structure implementers
(and users).
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to