pingcap / talent-plan

open source training courses about distributed database and distributed systems
https://tidb.io/talent-plan
10.1k stars 1.3k forks source link

fix bug (courses/dss): remove unnecessary nested match from clippy #387

Closed ccbrucer closed 3 years ago

ccbrucer commented 3 years ago

What problem does this PR solve?

For the raft lab, when compiling with rustc 1.50.0, clippy issues the error: Unnecessary nested match for the file raft/src/raft/tests.rs:693:17.

What is changed and how it works?

The original code is

            if let Some(Some(raft)) = rafts.get_mut(i) {
                if let Some(raft) = raft {
                    if raft.start(&random_entry(&mut random)).is_ok() {
                        leader = Some(i);
                    }
                }
            }

The code has been changed to

            if let Some(Some(raft)) = rafts.get_mut(i) {
                if raft.start(&random_entry(&mut random)).is_ok() {
                    leader = Some(i);
                }
            }

By reducing nested match, the error is fixed.

Check List

Tests

Side effects

Related changes