@@ -40,14 +40,14 @@ impl<'hist> MBox<'hist> {
4040 let mut avg_color = weighed_average_color ( hist) ;
4141 // It's possible that an average color will end up being bad for every entry,
4242 // so prefer picking actual colors so that at least one histogram entry will be satisfied.
43- if ( hist. len ( ) < 500 && hist. len ( ) > 2 ) || Self :: is_useless_color ( & avg_color, hist, other_boxes) {
43+ if ( hist. len ( ) < 500 && hist. len ( ) > 2 ) || Self :: is_useless_color ( avg_color, hist, other_boxes) {
4444 avg_color = hist. iter ( ) . min_by_key ( |a| OrdFloat :: new ( avg_color. diff ( & a. color ) ) ) . map ( |a| a. color ) . unwrap_or_default ( ) ;
4545 }
4646 Self :: new_c ( hist, adjusted_weight_sum, avg_color)
4747 }
4848
4949 fn new_c ( hist : & ' hist mut [ HistItem ] , adjusted_weight_sum : f64 , avg_color : f_pixel ) -> Self {
50- let ( variance, max_error) = Self :: box_stats ( hist, & avg_color) ;
50+ let ( variance, max_error) = Self :: box_stats ( hist, avg_color) ;
5151 Self {
5252 variance,
5353 max_error,
@@ -59,7 +59,7 @@ impl<'hist> MBox<'hist> {
5959 }
6060
6161 /// It's possible that the average color is useless
62- fn is_useless_color ( new_avg_color : & f_pixel , colors : & [ HistItem ] , other_boxes : & [ MBox < ' _ > ] ) -> bool {
62+ fn is_useless_color ( new_avg_color : f_pixel , colors : & [ HistItem ] , other_boxes : & [ MBox < ' _ > ] ) -> bool {
6363 colors. iter ( ) . all ( move |c| {
6464 let own_box_diff = new_avg_color. diff ( & c. color ) ;
6565 let other_box_is_better = other_boxes. iter ( )
@@ -69,7 +69,7 @@ impl<'hist> MBox<'hist> {
6969 } )
7070 }
7171
72- fn box_stats ( hist : & [ HistItem ] , avg_color : & f_pixel ) -> ( ARGBF , f32 ) {
72+ fn box_stats ( hist : & [ HistItem ] , avg_color : f_pixel ) -> ( ARGBF , f32 ) {
7373 let mut variance = ARGBF :: default ( ) ;
7474 let mut max_error = 0. ;
7575 for a in hist {
@@ -278,9 +278,8 @@ impl<'hist> MedianCutter<'hist> {
278278 // later raises the limit to allow large smooth areas/gradients get colors.
279279 let fraction_done = self . boxes . len ( ) as f64 / f64:: from ( self . target_colors ) ;
280280 let current_max_mse = ( fraction_done * 16. ) . mul_add ( max_mse, max_mse) ;
281- let bi = match self . take_best_splittable_box ( current_max_mse) {
282- Some ( bi) => bi,
283- None => break ,
281+ let Some ( bi) = self . take_best_splittable_box ( current_max_mse) else {
282+ break
284283 } ;
285284
286285 self . boxes . extend ( bi. split ( & self . boxes ) ) ;
0 commit comments