RFC: Add DerefMove by ftxqxd · Pull Request #178 · rust-lang/rfcs (original) (raw)

I feel like I am missing something in this second bullet: Whether we choose to move or copy a value is based on the static type of that value's expression. If I implement Deref<C> on Foo (for some C:Copy), then *foo will copy rather than move, right? Therefore, this specification seems circular, e.g. if I also implement DerefMove<Box<()>> on Foo as well, then I need to know the type of an expression like *foo to know whether its return value is being copied or being moved, but in order to know what the type of *foo is, I need to know whether I am supposed to be invoking deref or deref_move.

But perhaps I have misunderstood your intention, and there is some other property that you are trying to describe here that is unrelated to the type-based move/copy distinction. And if that is the case, perhaps there is another phrasing that would be clearer here. (I'm just guessing now, but would "if the dereference is in an rvalue context" work?)