[rust-dev] Why doesn't rust require "mut" param prefix at call site?

Patrick Walton pcwalton at mozilla.com
Thu Jan 2 14:51:24 PST 2014


On 1/2/14 2:49 PM, Vadim wrote:
> I'd say it should be i(mut x, ...), though in this case inferring borrow
> is not possible because of the lambda.   But if this were a standalone
> function, e.g. the f() above, one could write "i(mut x, f);"
>
> Regarding mutation-polymorphic generics, yes, it may not be possible to
> mut-annotate them.  I would just let it slide for "pass-through" types
> like T, but require annotations in non-generic code.
> Not the best solution, but it just bothers me that we worry about the
> "mutability hazard" at the top level of the call chain, but then
> completely forget about it inside the callee.

I'd rather do something principled and easy to understand than to have 
ad-hoc rules that a user has to memorize. What current Rust does is easy 
to understand IMO: it's the same as C.

Patrick



More information about the Rust-dev mailing list