Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement Eq for Cell and RefCell. #25744
Conversation
rust-highfive
assigned
alexcrichton
May 24, 2015
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
This comment has been minimized.
This comment has been minimized.
|
There might be a reason why |
This comment has been minimized.
This comment has been minimized.
|
@tbu- I don’t understand how that’s more of a problem for |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin |
This comment has been minimized.
This comment has been minimized.
|
It’s not clear to me that “don’t panic” is a promise that |
This comment has been minimized.
This comment has been minimized.
|
Well, it'd be useful for |
This comment has been minimized.
This comment has been minimized.
|
Anyway, here is how I came to this:
If there is a good reason not to implement |
This comment has been minimized.
This comment has been minimized.
|
I think that the cc @rust-lang/libs, do others have a strong opinion one way or another about this? |
alexcrichton
added
the
T-libs
label
May 26, 2015
This comment has been minimized.
This comment has been minimized.
|
I'm looking over the existing impls for |
This comment has been minimized.
This comment has been minimized.
|
I remember that |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The We could either treat it as "this should have never existed, and we're not going to add any more delegating trait implementations", or decide that it's fine, in which case we should probably add on impls of |
This comment has been minimized.
This comment has been minimized.
|
I consider the So, I'm +1 for adding these impls. |
This comment has been minimized.
This comment has been minimized.
|
@sfackler in the past we've found that omitting implementations of core traits from core types (e.g. |
This comment has been minimized.
This comment has been minimized.
|
I'm a bit leery in general of invisible sources of panics. |
This comment has been minimized.
This comment has been minimized.
|
True, although technically this PR introduces 0 extra panics because |
This comment has been minimized.
This comment has been minimized.
|
fwiw unsafe code already needs to guard against this sort of thing because "you never know". As such adding this is basically a "no-lose" scenario to me. |
SimonSapin commentedMay 24, 2015
core::cell::Cell<T>andcore::cell::RefCell<T>currently implementPartialEqwhenTdoes, and just defer to comparingTvalues. There is no reason the same shouldn’t apply toEq.This enables
#[derive(Eq, PartialEq)]on e.g. structs that have aRefCellfield.r? @alexcrichton
I’m unsure what to do with
#[stable]attributes onimpls.impls generated by#[derive]don’t have them.