Add contains method for ActiveValue
Open
@Diwakar-Gupta is already working on this.
Since Apr 25, 2023.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 735
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
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() and as_ref(). Which makes the code a bit more complicated.
Proposed Solutions
let id_set = ActiveValue::Set(1);
let id_unchanged = ActiveValue::Unchanged(1);
let id_not_set = ActiveValue::<i32>::NotSet;
id_set.contains(&1); // true
id_unchanged.contains(&1); // true
id_not_set.contains(&1); // false
Current Workarounds
let id_set = ActiveValue::Set(1);
!id_set.is_not_set() && id_set.as_ref() == &1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.