IssueRaiser

Extending deref/index with ownership transfer: DerefMove, IndexMove, IndexSet

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rfcs/issues/997)* It is clear that there is a need for the ability to move out of smart pointers and indexable things (`DerefMove`, `IndexMove`). The other frequently desired option is to `IndexSet`, which would be a special-cased version for indexing in this situation: ``` map[key] = value ``` currently, this is handled via `IndexMut`, but that is sub-optimal, because if the `key` is not already part of the `map`, the result is a panic. ### Basic plan DerefMove/IndexMove/IndexSet should layer on top of the traits we have now. One needs to be careful here because of subtle interactions with autoref and so forth. ### Postponed RFCs - https://github.com/rust-lang/rfcs/pull/178 - https://github.com/rust-lang/rfcs/pull/159 - https://github.com/rust-lang/rfcs/pull/1129 (`map[key] = value`)

Posted by nikomatsakis on Mar 21, 2015, 11:03 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.7,500 issues0 comments

github (Sysadmin)

Extending deref/index with ownership transfer: DerefMove, IndexMove, IndexSet

nikomatsakisMar 21, 2015, 11:03 AM

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rfcs/issues/997)* It is clear that there is a need for the ability to move out of smart pointers and indexable things (`DerefMove`, `IndexMove`). The other frequently desired option is to `IndexSet`, which would be a special-cased version for indexing in this situation: ``` map[key] = value ``` currently, this is handled via `IndexMut`, but that is sub-optimal, because if the `key` is not already part of the `map`, the result is a panic. ### Basic plan DerefMove/IndexMove/IndexSet should layer on top of the traits we have now. One needs to be careful here because of subtle interactions with autoref and so forth. ### Postponed RFCs - https://github.com/rust-lang/rfcs/pull/178 - https://github.com/rust-lang/rfcs/pull/159 - https://github.com/rust-lang/rfcs/pull/1129 (`map[key] = value`)

Comments (0)

No comments yet. Start the discussion.

Comment on this issue