Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d4c3126

Browse files
authored
style: include redundant_else (TheAlgorithms#860)
1 parent a11736a commit d4c3126

File tree

8 files changed

+16
-25
lines changed

8 files changed

+16
-25
lines changed

‎Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ must_use_candidate = { level = "allow", priority = 1 }
5959
needless_pass_by_value = { level = "allow", priority = 1 }
6060
range_plus_one = { level = "allow", priority = 1 }
6161
redundant_closure_for_method_calls = { level = "allow", priority = 1 }
62-
redundant_else = { level = "allow", priority = 1 }
6362
return_self_not_must_use = { level = "allow", priority = 1 }
6463
semicolon_if_nothing_returned = { level = "allow", priority = 1 }
6564
should_panic_without_expect = { level = "allow", priority = 1 }

‎src/data_structures/b_tree.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ where
152152
Err(index) => {
153153
if current_node.is_leaf() {
154154
return false;
155-
} else {
156-
current_node = &current_node.children[index];
157155
}
156+
current_node = &current_node.children[index];
158157
}
159158
}
160159
}

‎src/general/kmeans.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ macro_rules! impl_kmeans {
8888
{
8989
// We need to use `return` to break out of the `loop`
9090
return clustering;
91-
} else {
92-
clustering = new_clustering;
9391
}
92+
clustering = new_clustering;
9493
}
9594
}
9695
}

‎src/graph/depth_first_search_tic_tac_toe.rs‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@ fn main() {
9595
if result.is_none() {
9696
println!("Not a valid empty coordinate.");
9797
continue;
98-
}else{
99-
board[move_pos.y as usize][move_pos.x as usize] = Players::PlayerX;
98+
}
99+
board[move_pos.y as usize][move_pos.x as usize] = Players::PlayerX;
100100

101-
if win_check(Players::PlayerX, &board) {
102-
display_board(&board);
103-
println!("Player X Wins!");
104-
return;
105-
}
101+
if win_check(Players::PlayerX, &board) {
102+
display_board(&board);
103+
println!("Player X Wins!");
104+
return;
106105
}
107106

108107
//Find the best game plays from the current board state

‎src/searching/saddleback_search.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ pub fn saddleback_search(matrix: &[Vec<i32>], element: i32) -> (usize, usize) {
2222
// If the target element is smaller, move to the previous column (leftwards)
2323
if right_index == 0 {
2424
break; // If we reach the left-most column, exit the loop
25-
} else {
26-
right_index -= 1;
2725
}
26+
right_index -= 1;
2827
}
2928
}
3029
}

‎src/searching/ternary_search_min_max_recursive.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ pub fn ternary_search_max_rec(
1616
return ternary_search_max_rec(f, mid1, end, absolute_precision);
1717
} else if r1 > r2 {
1818
return ternary_search_max_rec(f, start, mid2, absolute_precision);
19-
} else {
20-
return ternary_search_max_rec(f, mid1, mid2, absolute_precision);
2119
}
20+
return ternary_search_max_rec(f, mid1, mid2, absolute_precision);
2221
}
2322
f(start)
2423
}
@@ -41,9 +40,8 @@ pub fn ternary_search_min_rec(
4140
return ternary_search_min_rec(f, start, mid2, absolute_precision);
4241
} else if r1 > r2 {
4342
return ternary_search_min_rec(f, mid1, end, absolute_precision);
44-
} else {
45-
return ternary_search_min_rec(f, mid1, mid2, absolute_precision);
4643
}
44+
return ternary_search_min_rec(f, mid1, mid2, absolute_precision);
4745
}
4846
f(start)
4947
}

‎src/string/aho_corasick.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ impl AhoCorasick {
5151
child.lengths.extend(node.borrow().lengths.clone());
5252
child.suffix = Rc::downgrade(node);
5353
break;
54-
} else {
55-
suffix = suffix.unwrap().borrow().suffix.upgrade();
5654
}
55+
suffix = suffix.unwrap().borrow().suffix.upgrade();
5756
}
5857
}
5958
}

‎src/string/jaro_winkler_distance.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ pub fn jaro_winkler_distance(str1: &str, str2: &str) -> f64 {
4343
let jaro: f64 = {
4444
if match_count == 0 {
4545
return 0.0;
46-
} else {
47-
(1_f64 / 3_f64)
48-
* (match_count as f64 / str1.len() as f64
49-
+ match_count as f64 / str2.len() as f64
50-
+ (match_count - transpositions) as f64 / match_count as f64)
5146
}
47+
(1_f64 / 3_f64)
48+
* (match_count as f64 / str1.len() as f64
49+
+ match_count as f64 / str2.len() as f64
50+
+ (match_count - transpositions) as f64 / match_count as f64)
5251
};
5352

5453
let mut prefix_len = 0.0;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /