Explorar el Código

Fix some clippy warnings

Johannes Hofmann hace 8 años
padre
commit
1191d2d674
Se han modificado 2 ficheros con 20 adiciones y 21 borrados
  1. 5
    5
      src/main.rs
  2. 15
    16
      src/tile_loader.rs

+ 5
- 5
src/main.rs Ver fichero

@@ -51,8 +51,8 @@ struct InputState {
51 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 56
         Event::Closed => Action::Close,
57 57
         Event::Awakened => Action::Redraw,
58 58
         Event::MouseInput(ElementState::Pressed, MouseButton::Left, position) => {
@@ -199,7 +199,7 @@ fn main() {
199 199
 
200 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 203
             Action::Close => break 'outer,
204 204
             Action::Redraw => {
205 205
                 redraw = true;
@@ -208,7 +208,7 @@ fn main() {
208 208
         }
209 209
 
210 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 212
                 Action::Close => break 'outer,
213 213
                 Action::Redraw => {
214 214
                     redraw = true;
@@ -224,7 +224,7 @@ fn main() {
224 224
                     std::thread::sleep(dur);
225 225
 
226 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 228
                             Action::Close => break 'outer,
229 229
                             Action::Redraw => {
230 230
                                 redraw = true;

+ 15
- 16
src/tile_loader.rs Ver fichero

@@ -35,7 +35,7 @@ impl TileLoader {
35 35
 
36 36
         TileLoader {
37 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 39
             request_tx: request_tx,
40 40
             result_rx: result_rx,
41 41
             pending: HashSet::new(),
@@ -43,8 +43,8 @@ impl TileLoader {
43 43
     }
44 44
 
45 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 48
         notice_func: F,
49 49
     )
50 50
         where F: Fn(Tile) + Sync + Send + 'static,
@@ -118,7 +118,7 @@ impl TileLoader {
118 118
                     Some(request) => {
119 119
                         match image::open(&request.path) {
120 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 122
                                     break 'outer;
123 123
                                 }
124 124
                                 arc_notice_func(request.tile);
@@ -207,18 +207,17 @@ impl TileLoader {
207 207
 
208 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