Skip to content

style: include redundant_else #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ must_use_candidate = { level = "allow", priority = 1 }
needless_pass_by_value = { level = "allow", priority = 1 }
range_plus_one = { level = "allow", priority = 1 }
redundant_closure_for_method_calls = { level = "allow", priority = 1 }
redundant_else = { level = "allow", priority = 1 }
return_self_not_must_use = { level = "allow", priority = 1 }
semicolon_if_nothing_returned = { level = "allow", priority = 1 }
should_panic_without_expect = { level = "allow", priority = 1 }
Expand Down
3 changes: 1 addition & 2 deletions src/data_structures/b_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ where
Err(index) => {
if current_node.is_leaf() {
return false;
} else {
current_node = &current_node.children[index];
}
current_node = &current_node.children[index];
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/general/kmeans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ macro_rules! impl_kmeans {
{
// We need to use `return` to break out of the `loop`
return clustering;
} else {
clustering = new_clustering;
}
clustering = new_clustering;
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/graph/depth_first_search_tic_tac_toe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ fn main() {
if result.is_none() {
println!("Not a valid empty coordinate.");
continue;
} else {
board[move_pos.y as usize][move_pos.x as usize] = Players::PlayerX;
}
board[move_pos.y as usize][move_pos.x as usize] = Players::PlayerX;

if win_check(Players::PlayerX, &board) {
display_board(&board);
println!("Player X Wins!");
return;
}
if win_check(Players::PlayerX, &board) {
display_board(&board);
println!("Player X Wins!");
return;
}

//Find the best game plays from the current board state
Expand Down
3 changes: 1 addition & 2 deletions src/searching/saddleback_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ pub fn saddleback_search(matrix: &[Vec<i32>], element: i32) -> (usize, usize) {
// If the target element is smaller, move to the previous column (leftwards)
if right_index == 0 {
break; // If we reach the left-most column, exit the loop
} else {
right_index -= 1;
}
right_index -= 1;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/searching/ternary_search_min_max_recursive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ pub fn ternary_search_max_rec(
return ternary_search_max_rec(f, mid1, end, absolute_precision);
} else if r1 > r2 {
return ternary_search_max_rec(f, start, mid2, absolute_precision);
} else {
return ternary_search_max_rec(f, mid1, mid2, absolute_precision);
}
return ternary_search_max_rec(f, mid1, mid2, absolute_precision);
}
f(start)
}
Expand All @@ -41,9 +40,8 @@ pub fn ternary_search_min_rec(
return ternary_search_min_rec(f, start, mid2, absolute_precision);
} else if r1 > r2 {
return ternary_search_min_rec(f, mid1, end, absolute_precision);
} else {
return ternary_search_min_rec(f, mid1, mid2, absolute_precision);
}
return ternary_search_min_rec(f, mid1, mid2, absolute_precision);
}
f(start)
}
Expand Down
3 changes: 1 addition & 2 deletions src/string/aho_corasick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ impl AhoCorasick {
child.lengths.extend(node.borrow().lengths.clone());
child.suffix = Rc::downgrade(node);
break;
} else {
suffix = suffix.unwrap().borrow().suffix.upgrade();
}
suffix = suffix.unwrap().borrow().suffix.upgrade();
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/string/jaro_winkler_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ pub fn jaro_winkler_distance(str1: &str, str2: &str) -> f64 {
let jaro: f64 = {
if match_count == 0 {
return 0.0;
} else {
(1_f64 / 3_f64)
* (match_count as f64 / str1.len() as f64
+ match_count as f64 / str2.len() as f64
+ (match_count - transpositions) as f64 / match_count as f64)
}
(1_f64 / 3_f64)
* (match_count as f64 / str1.len() as f64
+ match_count as f64 / str2.len() as f64
+ (match_count - transpositions) as f64 / match_count as f64)
};

let mut prefix_len = 0.0;
Expand Down
Loading