Skip to content

style: include unnecessary_wraps #762

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
Jul 6, 2024
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 @@ -74,7 +74,6 @@ stable_sort_primitive = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
trivially_copy_pass_by_ref = { level = "allow", priority = 1 }
unnecessary_box_returns = { level = "allow", priority = 1 }
unnecessary_wraps = { level = "allow", priority = 1 }
unnested_or_patterns = { level = "allow", priority = 1 }
unreadable_literal = { level = "allow", priority = 1 }
unused_self = { level = "allow", priority = 1 }
Expand Down
11 changes: 4 additions & 7 deletions src/backtracking/graph_coloring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn generate_colorings(
adjacency_matrix: Vec<Vec<bool>>,
num_colors: usize,
) -> Result<Option<Vec<Vec<usize>>>, GraphColoringError> {
GraphColoring::new(adjacency_matrix)?.find_solutions(num_colors)
Ok(GraphColoring::new(adjacency_matrix)?.find_solutions(num_colors))
}

/// A struct representing a graph coloring problem.
Expand Down Expand Up @@ -126,15 +126,12 @@ impl GraphColoring {
/// # Returns
///
/// * A `Result` containing an `Option` with a vector of solutions or a `GraphColoringError`.
fn find_solutions(
&mut self,
num_colors: usize,
) -> Result<Option<Vec<Vec<usize>>>, GraphColoringError> {
fn find_solutions(&mut self, num_colors: usize) -> Option<Vec<Vec<usize>>> {
self.find_colorings(0, num_colors);
if self.solutions.is_empty() {
Ok(None)
None
} else {
Ok(Some(std::mem::take(&mut self.solutions)))
Some(std::mem::take(&mut self.solutions))
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/sorting/tree_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ impl<T: Ord + Clone> BinarySearchTree<T> {
}

fn insert(&mut self, value: T) {
self.root = Self::insert_recursive(self.root.take(), value);
self.root = Some(Self::insert_recursive(self.root.take(), value));
}

fn insert_recursive(root: Option<Box<TreeNode<T>>>, value: T) -> Option<Box<TreeNode<T>>> {
fn insert_recursive(root: Option<Box<TreeNode<T>>>, value: T) -> Box<TreeNode<T>> {
match root {
None => Some(Box::new(TreeNode::new(value))),
None => Box::new(TreeNode::new(value)),
Some(mut node) => {
if value <= node.value {
node.left = Self::insert_recursive(node.left.take(), value);
node.left = Some(Self::insert_recursive(node.left.take(), value));
} else {
node.right = Self::insert_recursive(node.right.take(), value);
node.right = Some(Self::insert_recursive(node.right.take(), value));
}
Some(node)
node
}
}
}
Expand Down