Pārlūkot izejas kodu

Fix clippy warnings

Johannes Hofmann 7 gadus atpakaļ
vecāks
revīzija
fcbad65155
14 mainītis faili ar 62 papildinājumiem un 79 dzēšanām
  1. 2
    4
      src/args.rs
  2. 3
    3
      src/buffer.rs
  3. 4
    4
      src/config.rs
  4. 1
    1
      src/context.rs
  5. 9
    24
      src/coord.rs
  6. 1
    1
      src/main.rs
  7. 9
    9
      src/map_view.rs
  8. 4
    4
      src/map_view_gl.rs
  9. 4
    4
      src/program.rs
  10. 8
    8
      src/texture.rs
  11. 2
    2
      src/tile.rs
  12. 5
    5
      src/tile_atlas.rs
  13. 6
    6
      src/tile_loader.rs
  14. 4
    4
      src/tile_source.rs

+ 2
- 4
src/args.rs Parādīt failu

@@ -3,7 +3,7 @@ use clap::Arg;
3 3
 
4 4
 
5 5
 pub fn parse<'a>() -> clap::ArgMatches<'a> {
6
-    let matches = clap::App::new("DeltaMap")
6
+    clap::App::new("DeltaMap")
7 7
         .version(crate_version!())
8 8
         .author(crate_authors!())
9 9
         .about(crate_description!())
@@ -38,7 +38,5 @@ pub fn parse<'a>() -> clap::ArgMatches<'a> {
38 38
             .long("sync")
39 39
             .help("Load tiles in a synchronous fashion. \
40 40
                 The UI is blocked while tiles are loading."))
41
-        .get_matches();
42
-
43
-    matches
41
+        .get_matches()
44 42
 }

+ 3
- 3
src/buffer.rs Parādīt failu

@@ -41,9 +41,9 @@ impl<'a> Buffer<'a> {
41 41
         }
42 42
 
43 43
         Buffer {
44
-            cx: cx,
45
-            buffer_obj: buffer_obj,
46
-            num_elements: num_elements,
44
+            cx,
45
+            buffer_obj,
46
+            num_elements,
47 47
         }
48 48
     }
49 49
 

+ 4
- 4
src/config.rs Parādīt failu

@@ -156,11 +156,11 @@ impl Config {
156 156
 
157 157
                 Ok(
158 158
                     Config {
159
-                        tile_cache_dir: tile_cache_dir,
159
+                        tile_cache_dir,
160 160
                         sources: vec![],
161
-                        fps: fps,
162
-                        use_network: use_network,
163
-                        async: async,
161
+                        fps,
162
+                        use_network,
163
+                        async,
164 164
                     }
165 165
                 )
166 166
             },

+ 1
- 1
src/context.rs Parādīt failu

@@ -34,7 +34,7 @@ macro_rules! check_gl_errors {
34 34
 impl Context {
35 35
     pub fn from_gl_window(window: &glutin::GlWindow) -> Context {
36 36
         let gl = gl::Gl::load_with(|ptr| window.get_proc_address(ptr) as *const _);
37
-        let cx = Context { gl: gl };
37
+        let cx = Context { gl };
38 38
 
39 39
         // Initialize a vertex array object (VAO) if the current OpenGL context supports it. VAOs are
40 40
         // not OpenGL ES 2.0 compatible, but are required for rendering with a core context.

+ 9
- 24
src/coord.rs Parādīt failu

@@ -11,10 +11,7 @@ pub struct MapCoord {
11 11
 
12 12
 impl MapCoord {
13 13
     pub fn new(x: f64, y: f64) -> MapCoord {
14
-        MapCoord {
15
-            x: x,
16
-            y: y,
17
-        }
14
+        MapCoord { x, y }
18 15
     }
19 16
 
20 17
     pub fn from_latlon(latitude: f64, longitude: f64) -> MapCoord {
@@ -22,26 +19,16 @@ impl MapCoord {
22 19
         let pi_lat = latitude * (PI / 180.0);
23 20
         let y = f64::ln(f64::tan(pi_lat) + 1.0 / f64::cos(pi_lat)) * (-0.5 / PI) + 0.5;
24 21
 
25
-        MapCoord {
26
-            x: x,
27
-            y: y,
28
-        }
22
+        MapCoord { x, y }
29 23
     }
30 24
 
31 25
     //TODO differ between normalized and not normalized tiles
32 26
     pub fn on_tile_at_zoom(&self, zoom: u32) -> TileCoord {
33 27
         let zoom_factor = f64::powi(2.0, zoom as i32);
34
-        let ix = (self.x * zoom_factor).floor() as i32;
35
-        let iy = (self.y * zoom_factor).floor() as i32;
28
+        let x = (self.x * zoom_factor).floor() as i32;
29
+        let y = (self.y * zoom_factor).floor() as i32;
36 30
 
37
-        let x = ix;
38
-        let y = iy;
39
-
40
-        TileCoord {
41
-            zoom: zoom,
42
-            x: x,
43
-            y: y,
44
-        }
31
+        TileCoord { zoom, x, y }
45 32
     }
46 33
 
47 34
     pub fn normalize_x(&mut self) {
@@ -68,11 +55,9 @@ pub struct ScreenCoord {
68 55
 
69 56
 impl ScreenCoord {
70 57
     pub fn new(x: f64, y: f64) -> Self {
71
-        ScreenCoord {
72
-            x: x,
73
-            y: y,
74
-        }
58
+        ScreenCoord { x, y }
75 59
     }
60
+
76 61
     pub fn snap_to_pixel(&mut self) {
77 62
         self.x = self.x.floor();
78 63
         self.y = self.y.floor();
@@ -168,9 +153,9 @@ pub struct TileCoord {
168 153
 impl TileCoord {
169 154
     pub fn new(zoom: u32, x: i32, y: i32) -> TileCoord {
170 155
         TileCoord {
171
-            zoom: zoom,
156
+            zoom,
172 157
             x: Self::normalize_coord(x, zoom),
173
-            y: y,
158
+            y,
174 159
         }
175 160
     }
176 161
 

+ 1
- 1
src/main.rs Parādīt failu

@@ -334,7 +334,7 @@ impl<'a> TileSources<'a> {
334 334
         } else {
335 335
             Some(TileSources {
336 336
                 current_index: 0,
337
-                sources: sources,
337
+                sources,
338 338
             })
339 339
         }
340 340
     }

+ 9
- 9
src/map_view.rs Parādīt failu

@@ -31,11 +31,11 @@ impl MapView {
31 31
     /// Constructs a new `MapView`.
32 32
     pub fn new(width: f64, height: f64, tile_size: u32, center: MapCoord, zoom: f64) -> MapView {
33 33
         MapView {
34
-            width: width,
35
-            height: height,
36
-            tile_size: tile_size,
37
-            center: center,
38
-            zoom: zoom,
34
+            width,
35
+            height,
36
+            tile_size,
37
+            center,
38
+            zoom,
39 39
             tile_zoom_offset: 0.0,
40 40
         }
41 41
     }
@@ -46,11 +46,11 @@ impl MapView {
46 46
         let min_dimension = width.min(height);
47 47
         let zoom = (min_dimension / f64::from(tile_size)).log2().ceil();
48 48
         MapView {
49
-            width: width,
50
-            height: height,
51
-            tile_size: tile_size,
49
+            width,
50
+            height,
51
+            tile_size,
52 52
             center: MapCoord::new(0.5, 0.5),
53
-            zoom: zoom,
53
+            zoom,
54 54
             tile_zoom_offset: 0.0,
55 55
         }
56 56
     }

+ 4
- 4
src/map_view_gl.rs Parādīt failu

@@ -73,11 +73,11 @@ impl<'a> MapViewGl<'a> {
73 73
         let map_view = MapView::with_filling_zoom(f64::from(initial_size.0), f64::from(initial_size.1), tile_size);
74 74
 
75 75
         MapViewGl {
76
-            cx: cx,
77
-            program: program,
78
-            buf: buf,
76
+            cx,
77
+            program,
78
+            buf,
79 79
             viewport_size: initial_size,
80
-            map_view: map_view,
80
+            map_view,
81 81
             tile_cache: TileCache::new(move |_tile| update_func(), use_network),
82 82
             tile_atlas: TileAtlas::new(tex, 256, use_async),
83 83
         }

+ 4
- 4
src/program.rs Parādīt failu

@@ -92,10 +92,10 @@ impl<'a> Program<'a> {
92 92
             };
93 93
 
94 94
             Ok(Program {
95
-                cx: cx,
96
-                vert_obj: vert_obj,
97
-                frag_obj: frag_obj,
98
-                program_obj: program_obj,
95
+                cx,
96
+                vert_obj,
97
+                frag_obj,
98
+                program_obj,
99 99
                 tex_ids: vec![],
100 100
                 tex_locations: vec![],
101 101
             })

+ 8
- 8
src/texture.rs Parādīt failu

@@ -38,10 +38,10 @@ impl<'a> Texture<'a> {
38 38
     }
39 39
 
40 40
     fn from_ptr(cx: &'a Context, width: u32, height: u32, format: TextureFormat, data_ptr: *const c_void) -> Texture<'a> {
41
-        let mut tex_obj = 0_u32;
41
+        let mut texture_obj = 0_u32;
42 42
         unsafe {
43
-            cx.gl.GenTextures(1, &mut tex_obj);
44
-            cx.gl.BindTexture(context::gl::TEXTURE_2D, tex_obj);
43
+            cx.gl.GenTextures(1, &mut texture_obj);
44
+            cx.gl.BindTexture(context::gl::TEXTURE_2D, texture_obj);
45 45
 
46 46
             cx.gl.TexParameteri(context::gl::TEXTURE_2D, context::gl::TEXTURE_MIN_FILTER, context::gl::LINEAR as i32);
47 47
             cx.gl.TexParameteri(context::gl::TEXTURE_2D, context::gl::TEXTURE_MAG_FILTER, context::gl::LINEAR as i32);
@@ -61,11 +61,11 @@ impl<'a> Texture<'a> {
61 61
         }
62 62
 
63 63
         Texture {
64
-            cx: cx,
65
-            texture_obj: tex_obj,
66
-            width: width,
67
-            height: height,
68
-            format: format,
64
+            cx,
65
+            texture_obj,
66
+            width,
67
+            height,
68
+            format,
69 69
         }
70 70
     }
71 71
 

+ 2
- 2
src/tile.rs Parādīt failu

@@ -11,8 +11,8 @@ pub struct Tile {
11 11
 impl Tile {
12 12
     pub fn new(coord: TileCoord, source_id: TileSourceId) -> Tile {
13 13
         Tile {
14
-            coord: coord,
15
-            source_id: source_id,
14
+            coord,
15
+            source_id,
16 16
         }
17 17
     }
18 18
 }

+ 5
- 5
src/tile_atlas.rs Parādīt failu

@@ -43,7 +43,7 @@ impl<'a> TileAtlas<'a> {
43 43
         self.slots_lru.reserve(num_slots);
44 44
         for x in 0..slots_x {
45 45
             for y in 0..slots_y {
46
-                let slot = CacheSlot { x: x, y: y };
46
+                let slot = CacheSlot { x, y };
47 47
                 self.slots_lru.insert(slot, None);
48 48
             }
49 49
         }
@@ -56,10 +56,10 @@ impl<'a> TileAtlas<'a> {
56 56
     pub fn new(tex: Texture<'a>, tile_size: u32, use_async: bool) -> Self {
57 57
         let mut atlas = TileAtlas {
58 58
             texture: tex,
59
-            tile_size: tile_size,
59
+            tile_size,
60 60
             slots_lru: LinkedHashMap::new(),
61 61
             tile_to_slot: HashMap::new(),
62
-            use_async: use_async,
62
+            use_async,
63 63
         };
64 64
 
65 65
         atlas.init();
@@ -172,7 +172,7 @@ impl<'a> TileAtlas<'a> {
172 172
                 tvt.push(
173 173
                     TexturedVisibleTile {
174 174
                         screen_rect: vt.rect,
175
-                        tex_rect: tex_rect,
175
+                        tex_rect,
176 176
                         tex_minmax: tex_rect.inset(inset_x, inset_y),
177 177
                     }
178 178
                 );
@@ -210,7 +210,7 @@ impl<'a> TileAtlas<'a> {
210 210
                         tvt.push(
211 211
                             TexturedVisibleTile {
212 212
                                 screen_rect: vt.rect.subdivide(&child_sub_coord),
213
-                                tex_rect: tex_rect,
213
+                                tex_rect,
214 214
                                 tex_minmax: tex_rect.inset(inset_x, inset_y),
215 215
                             }
216 216
                         );

+ 6
- 6
src/tile_loader.rs Parādīt failu

@@ -37,10 +37,10 @@ impl TileLoader {
37 37
         TileLoader {
38 38
             client: None,
39 39
             join_handle: thread::spawn(move || Self::work(&request_rx, &result_tx, notice_func, use_network)),
40
-            request_tx: request_tx,
41
-            result_rx: result_rx,
40
+            request_tx,
41
+            result_rx,
42 42
             pending: HashSet::new(),
43
-            use_network: use_network,
43
+            use_network,
44 44
         }
45 45
     }
46 46
 
@@ -225,10 +225,10 @@ impl TileLoader {
225 225
             if let Some(url) = source.remote_tile_url(tile_coord) {
226 226
                 if self.request_tx.send(LoaderMessage::GetTile(
227 227
                         TileRequest {
228
-                            tile: tile,
229
-                            url: url,
228
+                            tile,
229
+                            url,
230 230
                             path: source.local_tile_path(tile_coord),
231
-                            write_to_file: write_to_file,
231
+                            write_to_file,
232 232
                         }
233 233
                     )).is_ok()
234 234
                 {

+ 4
- 4
src/tile_source.rs Parādīt failu

@@ -27,12 +27,12 @@ impl TileSource {
27 27
         max_zoom: u32,
28 28
     ) -> Self {
29 29
         TileSource {
30
-            id: id,
30
+            id,
31 31
             url_template: url_template.into(),
32 32
             directory: directory.into(),
33
-            extension: extension,
34
-            min_zoom: min_zoom,
35
-            max_zoom: max_zoom,
33
+            extension,
34
+            min_zoom,
35
+            max_zoom,
36 36
         }
37 37
     }
38 38