Skip to content

Conditional updates #2228

Answered by gbj
SorenHolstHansen asked this question in Q&A
Jan 25, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

This depends on the signature of purchase_artifact. If it takes &self then you can do a conditional update with something like:

match game_history.with(GameHistory::purchase_artifact) {
  Err(e) => show_error(e),
  Ok(value) => game_history.update(/* ... */)
}

If it takes &mut, then there is not a way to do this without the framework adding some additional PartialEq constraint or something, or creating a special helper method that doesn't currently exist.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SorenHolstHansen
Comment options

Answer selected by SorenHolstHansen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants