-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add Mut::clone_from_if_neq #17019
Add Mut::clone_from_if_neq #17019
Conversation
/// # schedule.run(&mut world); | ||
/// # assert!(!message_changed.run((), &mut world)); | ||
/// ``` | ||
fn clone_if_neq<T>(&mut self, value: &T) -> bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer an enum with 2 variants which are self describing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the return value? This is just to be consistent with set_if_neq
. If we were to add an enum for that, I would prefer doing that in a separate PR and change set_if_neq
together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really appreciate the motivation / doc tests on this method: my immediate reaction was "how is this useful"!
Since this behaves more like |
CI is still failing |
Agreed, I'd prefer |
625a171
to
df79451
Compare
@SOF3 |
@alice-i-cecile edits are open to maintainers, not sure why you can't push. I will update it myself later today anyway. |
Hmm, very odd. Thanks! |
um the CI failure doesn't look relevant to this PR |
|
Objective
clone_into
.Solution
ToOwned::clone_into
to copy a reference provided by the caller inMut::clone_from_if_neq
.Testing