Browse Source

Fix some clippy warnings

Johannes Hofmann 8 years ago
parent
commit
1191d2d674
2 changed files with 20 additions and 21 deletions
  1. 5
    5
      src/main.rs
  2. 15
    16
      src/tile_loader.rs

+ 5
- 5
src/main.rs View File

51
     mouse_pressed: bool,
51
     mouse_pressed: bool,
52
 }
52
 }
53
 
53
 
54
-fn handle_event(event: Event, map: &mut MapViewGl, input_state: &mut InputState, sources: &mut TileSources) -> Action {
55
-    match event {
54
+fn handle_event(event: &Event, map: &mut MapViewGl, input_state: &mut InputState, sources: &mut TileSources) -> Action {
55
+    match *event {
56
         Event::Closed => Action::Close,
56
         Event::Closed => Action::Close,
57
         Event::Awakened => Action::Redraw,
57
         Event::Awakened => Action::Redraw,
58
         Event::MouseInput(ElementState::Pressed, MouseButton::Left, position) => {
58
         Event::MouseInput(ElementState::Pressed, MouseButton::Left, position) => {
199
 
199
 
200
         let mut redraw = false;
200
         let mut redraw = false;
201
 
201
 
202
-        match handle_event(event, &mut map, &mut input_state, &mut sources) {
202
+        match handle_event(&event, &mut map, &mut input_state, &mut sources) {
203
             Action::Close => break 'outer,
203
             Action::Close => break 'outer,
204
             Action::Redraw => {
204
             Action::Redraw => {
205
                 redraw = true;
205
                 redraw = true;
208
         }
208
         }
209
 
209
 
210
         for event in window.poll_events() {
210
         for event in window.poll_events() {
211
-            match handle_event(event, &mut map, &mut input_state, &mut sources) {
211
+            match handle_event(&event, &mut map, &mut input_state, &mut sources) {
212
                 Action::Close => break 'outer,
212
                 Action::Close => break 'outer,
213
                 Action::Redraw => {
213
                 Action::Redraw => {
214
                     redraw = true;
214
                     redraw = true;
224
                     std::thread::sleep(dur);
224
                     std::thread::sleep(dur);
225
 
225
 
226
                     for event in window.poll_events() {
226
                     for event in window.poll_events() {
227
-                        match handle_event(event, &mut map, &mut input_state, &mut sources) {
227
+                        match handle_event(&event, &mut map, &mut input_state, &mut sources) {
228
                             Action::Close => break 'outer,
228
                             Action::Close => break 'outer,
229
                             Action::Redraw => {
229
                             Action::Redraw => {
230
                                 redraw = true;
230
                                 redraw = true;

+ 15
- 16
src/tile_loader.rs View File

35
 
35
 
36
         TileLoader {
36
         TileLoader {
37
             client: None,
37
             client: None,
38
-            join_handle: thread::spawn(move || Self::work(request_rx, result_tx, notice_func)),
38
+            join_handle: thread::spawn(move || Self::work(&request_rx, &result_tx, notice_func)),
39
             request_tx: request_tx,
39
             request_tx: request_tx,
40
             result_rx: result_rx,
40
             result_rx: result_rx,
41
             pending: HashSet::new(),
41
             pending: HashSet::new(),
43
     }
43
     }
44
 
44
 
45
     fn work<F>(
45
     fn work<F>(
46
-        request_rx: mpsc::Receiver<LoaderMessage>,
47
-        result_tx: mpsc::Sender<(Tile, Option<DynamicImage>)>,
46
+        request_rx: &mpsc::Receiver<LoaderMessage>,
47
+        result_tx: &mpsc::Sender<(Tile, Option<DynamicImage>)>,
48
         notice_func: F,
48
         notice_func: F,
49
     )
49
     )
50
         where F: Fn(Tile) + Sync + Send + 'static,
50
         where F: Fn(Tile) + Sync + Send + 'static,
118
                     Some(request) => {
118
                     Some(request) => {
119
                         match image::open(&request.path) {
119
                         match image::open(&request.path) {
120
                             Ok(img) => {
120
                             Ok(img) => {
121
-                                if let Err(_) = result_tx.send((request.tile, Some(img))) {
121
+                                if result_tx.send((request.tile, Some(img))).is_err() {
122
                                     break 'outer;
122
                                     break 'outer;
123
                                 }
123
                                 }
124
                                 arc_notice_func(request.tile);
124
                                 arc_notice_func(request.tile);
207
 
207
 
208
         let tile = Tile::new(tile_coord, source.id());
208
         let tile = Tile::new(tile_coord, source.id());
209
 
209
 
210
-        if !self.pending.contains(&tile) {
211
-            if self.request_tx.send(LoaderMessage::GetTile(
212
-                    TileRequest {
213
-                        tile: tile,
214
-                        url: source.remote_tile_url(tile_coord),
215
-                        path: source.local_tile_path(tile_coord),
216
-                        write_to_file: write_to_file,
217
-                    }
218
-                )).is_ok()
219
-            {
220
-                self.pending.insert(tile);
221
-            }
210
+        if !self.pending.contains(&tile) &&
211
+            self.request_tx.send(LoaderMessage::GetTile(
212
+                TileRequest {
213
+                    tile: tile,
214
+                    url: source.remote_tile_url(tile_coord),
215
+                    path: source.local_tile_path(tile_coord),
216
+                    write_to_file: write_to_file,
217
+                }
218
+            )).is_ok()
219
+        {
220
+            self.pending.insert(tile);
222
         }
221
         }
223
     }
222
     }
224
 
223