Skip to content

Commit 1f07677

Browse files
committed
Use "if let" for matching "State::Full"
1 parent 1b80402 commit 1f07677

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sync/src/block/extension.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use std::collections::hash_map::Entry;
1818
use std::collections::{HashMap, HashSet};
1919
use std::fs;
20-
use std::mem::discriminant;
2120
use std::sync::Arc;
2221
use std::time::Duration;
2322

@@ -261,7 +260,7 @@ impl Extension {
261260
fn move_state(&mut self) {
262261
let next_state = self.state.next(&self.client);
263262
cdebug!(SYNC, "Transitioning the state to {:?}", next_state);
264-
if discriminant(&next_state) == discriminant(&State::Full) {
263+
if let State::Full = next_state {
265264
let best_hash = match &self.state {
266265
State::SnapshotHeader(hash, _) => *hash,
267266
State::SnapshotBody {
@@ -294,7 +293,7 @@ impl Extension {
294293
}
295294

296295
fn send_status(&mut self, id: &NodeId) {
297-
if discriminant(&self.state) != discriminant(&State::Full) {
296+
if let State::Full = self.state {
298297
return
299298
}
300299

@@ -314,7 +313,7 @@ impl Extension {
314313
}
315314

316315
fn send_status_broadcast(&mut self) {
317-
if discriminant(&self.state) != discriminant(&State::Full) {
316+
if let State::Full = self.state {
318317
return
319318
}
320319

0 commit comments

Comments
 (0)