@@ -47,15 +47,11 @@ impl Application for State {
4747 Message :: MouseEvent ( event, point) => {
4848 self . chart . set_current_position ( point) ;
4949 match event {
50- iced:: mouse:: Event :: ButtonPressed ( button) => {
51- if let iced:: mouse:: Button :: Left = button {
52- self . chart . set_down ( true ) ;
53- }
50+ iced:: mouse:: Event :: ButtonPressed ( iced:: mouse:: Button :: Left ) => {
51+ self . chart . set_down ( true ) ;
5452 }
55- iced:: mouse:: Event :: ButtonReleased ( button) => {
56- if let iced:: mouse:: Button :: Left = button {
57- self . chart . set_down ( false ) ;
58- }
53+ iced:: mouse:: Event :: ButtonReleased ( iced:: mouse:: Button :: Left ) => {
54+ self . chart . set_down ( false ) ;
5955 }
6056 _ => {
6157 // Do nothing
@@ -116,12 +112,12 @@ impl ArtChart {
116112
117113 fn nearby ( p0 : ( f32 , f32 ) , p1 : ( f32 , f32 ) ) -> bool {
118114 let delta = ( p1. 0 - p0. 0 , p1. 1 - p0. 1 ) ;
119- return ( delta. 0 * delta. 0 + delta. 1 * delta. 1 ) . sqrt ( ) <= 1.0 ;
115+ ( delta. 0 * delta. 0 + delta. 1 * delta. 1 ) . sqrt ( ) <= 1.0
120116 }
121117
122118 fn set_down ( & mut self , new_is_down : bool ) {
123119 if !self . is_down && new_is_down {
124- self . initial_down_position = self . current_position . clone ( ) ;
120+ self . initial_down_position = self . current_position ;
125121 }
126122
127123 if self . is_down && !new_is_down {
@@ -163,9 +159,9 @@ impl Chart<Message> for ArtChart {
163159
164160 chart
165161 . configure_mesh ( )
166- . bold_line_style ( & colors:: BLACK . mix ( 0.1 ) )
167- . light_line_style ( & colors:: BLACK . mix ( 0.05 ) )
168- . axis_style ( ShapeStyle :: from ( & colors:: BLACK . mix ( 0.45 ) ) . stroke_width ( 1 ) )
162+ . bold_line_style ( colors:: BLACK . mix ( 0.1 ) )
163+ . light_line_style ( colors:: BLACK . mix ( 0.05 ) )
164+ . axis_style ( ShapeStyle :: from ( colors:: BLACK . mix ( 0.45 ) ) . stroke_width ( 1 ) )
169165 . y_labels ( 10 )
170166 . y_label_style (
171167 ( "sans-serif" , 15 )
@@ -181,7 +177,7 @@ impl Chart<Message> for ArtChart {
181177 . draw_series (
182178 self . points
183179 . iter ( )
184- . map ( |p| Circle :: new ( p . clone ( ) , 5_i32 , POINT_COLOR . filled ( ) ) ) ,
180+ . map ( |p| Circle :: new ( * p , 5_i32 , POINT_COLOR . filled ( ) ) ) ,
185181 )
186182 . expect ( "Failed to draw points" ) ;
187183
@@ -201,7 +197,7 @@ impl Chart<Message> for ArtChart {
201197 if Self :: nearby ( initial_p, current_p) {
202198 chart
203199 . draw_series ( std:: iter:: once ( Circle :: new (
204- current_p. clone ( ) ,
200+ current_p,
205201 5_i32 ,
206202 PREVIEW_COLOR . filled ( ) ,
207203 ) ) )
@@ -215,16 +211,14 @@ impl Chart<Message> for ArtChart {
215211 . expect ( "Failed to draw preview line" ) ;
216212 }
217213 }
218- } else {
219- if let Some ( current_p) = self . current_position {
220- chart
221- . draw_series ( std:: iter:: once ( Circle :: new (
222- current_p. clone ( ) ,
223- 5_i32 ,
224- HOVER_COLOR . filled ( ) ,
225- ) ) )
226- . expect ( "Failed to draw hover point" ) ;
227- }
214+ } else if let Some ( current_p) = self . current_position {
215+ chart
216+ . draw_series ( std:: iter:: once ( Circle :: new (
217+ current_p,
218+ 5_i32 ,
219+ HOVER_COLOR . filled ( ) ,
220+ ) ) )
221+ . expect ( "Failed to draw hover point" ) ;
228222 }
229223
230224 * self . spec . borrow_mut ( ) = Some ( chart. as_coord_spec ( ) . clone ( ) ) ;
0 commit comments