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 contains method for ActiveValue #1533
Comments
In which file i will find this issue |
@er-pratham It's supposed to be here |
Hey @negezor, interesting. I think implementing Such that we can simply write |
Hi @billy1624, I think this behavior is confusing. It sounds like |
@billy1624 Outcome assert!(ActiveValue::Set(2) == 2);
assert_ne!(ActiveValue::Set(2), 3);
assert_ne!(
ActiveValue::Unchanged(String::from("hi")),
String::from("bye")
);
assert!(ActiveValue::Unchanged(String::from("hi")) == String::from("hi")); impl<V, U> PartialEq<U> for ActiveValue<V>
where
V: Into<Value> + std::cmp::PartialEq<U>,
U: Into<Value>,
{
fn eq(&self, other: &U) -> bool {
match self {
Self::Set(value) | Self::Unchanged(value) => value.eq(other),
Self::NotSet => false,
}
}
} |
Hey @Diwakar-Gupta, the implementation looks promising!! Could you please file a PR for it? |
Motivation
Sometimes it is necessary to compare a value in a model that is already the active model. Now this is done somewhat inconveniently, you need to use
!is_not_set()
andas_ref()
. Which makes the code a bit more complicated.Proposed Solutions
Current Workarounds
The text was updated successfully, but these errors were encountered: