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 }
74
74
too_many_lines = { level = " allow" , priority = 1 }
75
75
trivially_copy_pass_by_ref = { level = " allow" , priority = 1 }
76
76
unnecessary_box_returns = { level = " allow" , priority = 1 }
77
- unnecessary_wraps = { level = " allow" , priority = 1 }
78
77
unnested_or_patterns = { level = " allow" , priority = 1 }
79
78
unreadable_literal = { level = " allow" , priority = 1 }
80
79
unused_self = { level = " allow" , priority = 1 }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub fn generate_colorings(
26
26
adjacency_matrix : Vec < Vec < bool > > ,
27
27
num_colors : usize ,
28
28
) -> 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) )
30
30
}
31
31
32
32
/// A struct representing a graph coloring problem.
@@ -126,15 +126,12 @@ impl GraphColoring {
126
126
/// # Returns
127
127
///
128
128
/// * 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 > > > {
133
130
self . find_colorings ( 0 , num_colors) ;
134
131
if self . solutions . is_empty ( ) {
135
- Ok ( None )
132
+ None
136
133
} else {
137
- Ok ( Some ( std:: mem:: take ( & mut self . solutions ) ) )
134
+ Some ( std:: mem:: take ( & mut self . solutions ) )
138
135
}
139
136
}
140
137
}
Original file line number Diff line number Diff line change @@ -30,19 +30,19 @@ impl<T: Ord + Clone> BinarySearchTree<T> {
30
30
}
31
31
32
32
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) ) ;
34
34
}
35
35
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 > > {
37
37
match root {
38
- None => Some ( Box :: new ( TreeNode :: new ( value) ) ) ,
38
+ None => Box :: new ( TreeNode :: new ( value) ) ,
39
39
Some ( mut node) => {
40
40
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) ) ;
42
42
} else {
43
- node. right = Self :: insert_recursive ( node. right . take ( ) , value) ;
43
+ node. right = Some ( Self :: insert_recursive ( node. right . take ( ) , value) ) ;
44
44
}
45
- Some ( node)
45
+ node
46
46
}
47
47
}
48
48
}
You can’t perform that action at this time.
0 commit comments