Skip to content

Commit 31a2976

Browse files
committed
f unwrap_or rather than if let
1 parent 2de8fe3 commit 31a2976

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

lightning/src/ln/channel.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -6603,11 +6603,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<(&'a K, u32)> for Channel<Signer>
66036603
// `user_id` used to be a single u64 value. In order to remain backwards
66046604
// compatible with versions prior to 0.0.113, the u128 is serialized as two
66056605
// separate u64 values.
6606-
let user_id = if let Some(user_id_high) = user_id_high_opt {
6607-
user_id_low as u128 + ((user_id_high as u128) << 64)
6608-
} else {
6609-
user_id_low as u128
6610-
};
6606+
let user_id = user_id_low as u128 + ((user_id_high_opt.unwrap_or(0) as u128) << 64);
66116607

66126608
Ok(Channel {
66136609
user_id,

lightning/src/util/events.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1054,13 +1054,9 @@ impl MaybeReadable for Event {
10541054
// `user_channel_id` used to be a single u64 value. In order to remain
10551055
// backwards compatible with versions prior to 0.0.113, the u128 is serialized
10561056
// as two separate u64 values.
1057-
let user_channel_id = if let Some(user_channel_id_low) = user_channel_id_low_opt {
1058-
if let Some(user_channel_id_high) = user_channel_id_high_opt {
1059-
user_channel_id_low as u128 + ((user_channel_id_high as u128) << 64)
1060-
} else {
1061-
user_channel_id_low as u128
1062-
}
1063-
} else { 0u128 };
1057+
let user_channel_id = (user_channel_id_low_opt.unwrap_or(0) as u128) +
1058+
((user_channel_id_high_opt.unwrap_or(0) as u128) << 64);
1059+
10641060
Ok(Some(Event::ChannelClosed { channel_id, user_channel_id, reason: reason.unwrap() }))
10651061
};
10661062
f()

0 commit comments

Comments
 (0)