Have you considered making deref the default instead and requiring moves to use
an explicit "move" keyword?
Basically, from this hypothetical syntax to current one:
- x => &x
- mut x => &mut x
- move x => x
One could even make the & implicit in parameter types in function declarations
unless the "move" keyword is used, so we would have (new => old syntax):
- fn(self, ...) => fn(&self, ...)
- fn(mut self, ...) => fn(&mut self, ...)
- fn(move self, ...) => fn(self, ...)
Regarding owned pointers, one could introduce this syntax:
let *x = func_that_gives_owned_pointer()
which makes x a variable of type T referring to the contents of the owned box,
and thus derefed to & when passed to a function as above without having to
write "*x" in the function call.
One could then add a new "#x" or similar syntax that would get back to the
owned pointer.
Not sure if all this is a good idea, just throwing it out there. I actually
think keeping autoref/autoderef is probably better.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev