Uh oh!
There was an error while loading. Please reload this page.
Implement Eq for Cell and RefCell. - #25744
Conversation
`core::cell::Cell<T>` and `core::cell::RefCell<T>` currently implement `PartialEq` when `T` does, and just defer to comparing `T` values. There is no reason the same shouldn’t apply to `Eq`. This enables `#[derive(Eq, PartialEq)]` on e.g. structs that have a `RefCell` field.
rust-highfive
commented
May 24, 2015
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. |
tbu-
commented
May 25, 2015
There might be a reason why |
SimonSapin
commented
May 25, 2015
@tbu- I don’t understand how that’s more of a problem for |
tbu-
commented
May 25, 2015
@SimonSapin |
SimonSapin
commented
May 25, 2015
It’s not clear to me that “don’t panic” is a promise that |
tbu-
commented
May 25, 2015
Well, it'd be useful for |
SimonSapin
commented
May 25, 2015
Anyway, here is how I came to this:
If there is a good reason not to implement |
alexcrichton
commented
May 26, 2015
I think that the cc @rust-lang/libs, do others have a strong opinion one way or another about this? |
BurntSushi
commented
May 26, 2015
I'm looking over the existing impls for |
Kimundi
commented
May 26, 2015
I remember that |
shepmaster
commented
May 26, 2015
sfackler
commented
May 27, 2015
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 |
aturon
commented
May 28, 2015
I consider the So, I'm +1 for adding these impls. |
alexcrichton
commented
May 28, 2015
@sfackler in the past we've found that omitting implementations of core traits from core types (e.g. |
sfackler
commented
May 28, 2015
I'm a bit leery in general of invisible sources of panics. |
alexcrichton
commented
May 28, 2015
True, although technically this PR introduces 0 extra panics because |
Gankra
commented
May 28, 2015
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. |
tbu-
commented
May 28, 2015
alexcrichton
commented
May 28, 2015
bors
commented
May 28, 2015
⌛ Testing commit bbf8ba7 with merge 53941be... |
`core::cell::Cell<T>` and `core::cell::RefCell<T>` currently implement `PartialEq` when `T` does, and just defer to comparing `T` values. There is no reason the same shouldn’t apply to `Eq`. This enables `#[derive(Eq, PartialEq)]` on e.g. structs that have a `RefCell` field. r? @alexcrichton I’m unsure what to do with `#[stable]` attributes on `impl`s. `impl`s generated by `#[derive]` don’t have them.
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.