Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/core/src/client/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ impl ToProtocol for TransactionUpdateMessage {
let TransactionUpdateMessage { event, database_update } = self;
let update = database_update.database_update;
protocol.assert_matches_format_switch(&update);
let request_id = database_update.request_id.unwrap_or(0);
let mut request_id = database_update.request_id.unwrap_or(0);
request_id = event.clone().map_or(request_id, |e| e.request_id.unwrap_or(request_id));
Comment on lines +283 to +284
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut request_id = database_update.request_id.unwrap_or(0);
request_id = event.clone().map_or(request_id, |e| e.request_id.unwrap_or(request_id));
let request_id = database_update.request_id
.or_else(|| event.as_ref().map(|event| event.request_id)
.unwrap_or(0);

No need to clone the event, and a functional style with Option combinators is better here than mutation.

match update {
FormatSwitch::Bsatn(update) => FormatSwitch::Bsatn(convert(event, request_id, update, |args| {
Vec::from(args.get_bsatn().clone()).into()
Expand Down
Loading