Skip to content

set_unset & friends for ActiveValue#3083

Open
PacificBird wants to merge 2 commits into
SeaQL:masterfrom
PacificBird:set-if-unset
Open

set_unset & friends for ActiveValue#3083
PacificBird wants to merge 2 commits into
SeaQL:masterfrom
PacificBird:set-if-unset

Conversation

@PacificBird

Copy link
Copy Markdown
Contributor

PR Info

New Features

  • ActiveValue::set_unset(&mut self, value: V), which mutates self to ActiveValue::Set(value) if self.is_not_set()
  • ActiveValue::set_unset(&mut self, value: impl FnOnce() -> V), which mutates self to ActiveValue::Set(f()) if self.is_not_set()
  • ActiveValue::set_unset(&mut self) where V: Default, which mutates self to ActiveValue::Set(V::default()) if self.is_not_set()

Includes documentation and examples/doc tests for all three. I cannot overstate how much grief these changes will save me in my production code base.

@Huliiiiii

Copy link
Copy Markdown
Member

I'd prefer the names set_if_unset / not_set, even though they’re a bit more verbose.
What do you think? @tyt2y3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Set if unset" methods for ActiveValues

2 participants