Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutable accessor for Copy single-element Cell-like container #44

Closed
dtolnay opened this issue May 3, 2017 · 3 comments
Closed

Mutable accessor for Copy single-element Cell-like container #44

dtolnay opened this issue May 3, 2017 · 3 comments

Comments

@dtolnay
Copy link
Member

dtolnay commented May 3, 2017

The guideline says:

Single-element containers where the element is Copy (e.g. Cell-like containers) should instead return the value directly, and not implement a mutable accessor.

And yet: Cell::get_mut

@Rufflewind
Copy link

That guideline is quite confusing. Why does the presence of Copy make mutable accessors undesirable?

@jonas-schievink
Copy link

@Rufflewind My guess is that set should be used to put a new value into the container.

Cell::get_mut is no longer limited to Copy types, by the way, so it now matches the guideline.

@dtolnay
Copy link
Member Author

dtolnay commented Oct 28, 2017

Cell now works for non-Copy types and exposes get_mut for them, so I removed this special case from the guidelines in ee56222.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants