On Friday, February 1, 2013, Chris Peterson wrote:
>
> Is it necessary to differentiate Mutable- and Immutable- container traits
> when mutating methods would take `&mut self` and read-only accessors take
> `&self`?



Well, we need the MutableMap-style traits, but we could fold the
ImmutableMap-style "insert into a copy" methods to Map. I don't think we
can rely on "&mut self" helping us out because it could be a source of
bugs. For example, if w forget a hashmap is currently immutable and do
"m.remove(x);" nothing actually happened.

It'd be safer if either we have different method names between
persistent insert/remove and mutating insert/remove, or just say if a type
is mutable and you want a copy you do "let n = copy m; n.insert(x)".
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to