File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ stable_sort_primitive = { level = "allow", priority = 1 }
7474too_many_lines = { level = " allow" , priority = 1 }
7575trivially_copy_pass_by_ref = { level = " allow" , priority = 1 }
7676unnecessary_box_returns = { level = " allow" , priority = 1 }
77- unnecessary_wraps = { level = " allow" , priority = 1 }
7877unnested_or_patterns = { level = " allow" , priority = 1 }
7978unreadable_literal = { level = " allow" , priority = 1 }
8079unused_self = { level = " allow" , priority = 1 }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub fn generate_colorings(
2626 adjacency_matrix : Vec < Vec < bool > > ,
2727 num_colors : usize ,
2828) -> Result < Option < Vec < Vec < usize > > > , GraphColoringError > {
29- GraphColoring :: new ( adjacency_matrix) ?. find_solutions ( num_colors)
29+ Ok ( GraphColoring :: new ( adjacency_matrix) ?. find_solutions ( num_colors) )
3030}
3131
3232/// A struct representing a graph coloring problem.
@@ -126,15 +126,12 @@ impl GraphColoring {
126126 /// # Returns
127127 ///
128128 /// * A `Result` containing an `Option` with a vector of solutions or a `GraphColoringError`.
129- fn find_solutions (
130- & mut self ,
131- num_colors : usize ,
132- ) -> Result < Option < Vec < Vec < usize > > > , GraphColoringError > {
129+ fn find_solutions ( & mut self , num_colors : usize ) -> Option < Vec < Vec < usize > > > {
133130 self . find_colorings ( 0 , num_colors) ;
134131 if self . solutions . is_empty ( ) {
135- Ok ( None )
132+ None
136133 } else {
137- Ok ( Some ( std:: mem:: take ( & mut self . solutions ) ) )
134+ Some ( std:: mem:: take ( & mut self . solutions ) )
138135 }
139136 }
140137}
Original file line number Diff line number Diff line change @@ -30,19 +30,19 @@ impl<T: Ord + Clone> BinarySearchTree<T> {
3030 }
3131
3232 fn insert ( & mut self , value : T ) {
33- self . root = Self :: insert_recursive ( self . root . take ( ) , value) ;
33+ self . root = Some ( Self :: insert_recursive ( self . root . take ( ) , value) ) ;
3434 }
3535
36- fn insert_recursive ( root : Option < Box < TreeNode < T > > > , value : T ) -> Option < Box < TreeNode < T > > > {
36+ fn insert_recursive ( root : Option < Box < TreeNode < T > > > , value : T ) -> Box < TreeNode < T > > {
3737 match root {
38- None => Some ( Box :: new ( TreeNode :: new ( value) ) ) ,
38+ None => Box :: new ( TreeNode :: new ( value) ) ,
3939 Some ( mut node) => {
4040 if value <= node. value {
41- node. left = Self :: insert_recursive ( node. left . take ( ) , value) ;
41+ node. left = Some ( Self :: insert_recursive ( node. left . take ( ) , value) ) ;
4242 } else {
43- node. right = Self :: insert_recursive ( node. right . take ( ) , value) ;
43+ node. right = Some ( Self :: insert_recursive ( node. right . take ( ) , value) ) ;
4444 }
45- Some ( node)
45+ node
4646 }
4747 }
4848 }
You can’t perform that action at this time.
0 commit comments