If the concern is mutability rather than details of the indirection used, then one option would be:
let mut a = ~["y"]; push(mut a, b); It would be a bit odd to do: let mut x = 0; incr(mut x); instead of: incr(&mut x); as long as you're keeping a strict pointer vs. value mental model, but part of the motivation of considering this in the first place is a weakening of this model, so I'm not sure how it ends up on balance. Sort of starts to seem like passing modes on the caller side, though still implemented using explicit memory layout on the callee side and autoref/autoborrow acting as the bridge. On Wednesday, November 20, 2013, Patrick Walton wrote: > On 11/20/13 5:05 AM, Sanghyeon Seo wrote: > >> I am against this proposal. As I understand, we will still keep >> autoref, autoborrow, etc. in method calls. So I don't think inconsistency >> argument holds. Neither does local readability argument. >> > > It is a good point that a true emphasis on consistency between methods and > functions would have us perform auto-deref and auto-ref on all argument > positions. Then the LHS of `.` and arguments would truly be treated the > same way, which dovetails with UFCS pretty nicely. > > I'm pretty nervous about performing auto-ref on function arguments, > though, *especially* `&mut` auto-ref. For some reason I expect that this: > > let mut a = ~["x"]; > a.push("hi"); > > may mutate `a`, while: > > let mut a = ~["y"]; > push(a, b); > > will *not* mutate `a`. Do others have the same expectation? > > Patrick > > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev