2 次程式碼提交

作者 SHA1 備註 提交日期
  Johannes Hofmann fc3397e34a Ignore a clippy warning of type `option_option` 6 年之前
  Johannes Hofmann 20209a75e4 Fix clippy warnings `needless_doctest_main` 6 年之前
共有 2 個文件被更改,包括 31 次插入34 次删除
  1. 3
    0
      src/block.rs
  2. 28
    34
      src/lib.rs

+ 3
- 0
src/block.rs 查看文件

152
         }
152
         }
153
     }
153
     }
154
 
154
 
155
+    /// Performs an internal iteration step. Returns `None` until there is a value for the iterator to
156
+    /// return. Returns `Some(None)` to end the iteration.
155
     #[inline]
157
     #[inline]
158
+    #[allow(clippy::option_option)]
156
     fn step(&mut self) -> Option<Option<Element<'a>>> {
159
     fn step(&mut self) -> Option<Option<Element<'a>>> {
157
         match self.state {
160
         match self.state {
158
             ElementsIterState::Group => {
161
             ElementsIterState::Group => {

+ 28
- 34
src/lib.rs 查看文件

10
 osmpbf = "0.1"
10
 osmpbf = "0.1"
11
 ```
11
 ```
12
 
12
 
13
-and this to your crate root:
13
+and if you're using Rust 2015, add this line to the crate root:
14
 
14
 
15
 ```rust
15
 ```rust
16
 extern crate osmpbf;
16
 extern crate osmpbf;
22
 file:
22
 file:
23
 
23
 
24
 ```rust
24
 ```rust
25
-extern crate osmpbf;
26
-
27
-use osmpbf::*;
25
+use osmpbf::{ElementReader, Element};
28
 
26
 
29
-fn main() {
30
-    let reader = ElementReader::from_path("tests/test.osm.pbf").unwrap();
31
-    let mut ways = 0_u64;
27
+let reader = ElementReader::from_path("tests/test.osm.pbf").unwrap();
28
+let mut ways = 0_u64;
32
 
29
 
33
-    // Increment the counter by one for each way.
34
-    reader.for_each(|element| {
35
-        if let Element::Way(_) = element {
36
-            ways += 1;
37
-        }
38
-    }).unwrap();
30
+// Increment the counter by one for each way.
31
+reader.for_each(|element| {
32
+    if let Element::Way(_) = element {
33
+        ways += 1;
34
+    }
35
+}).unwrap();
39
 
36
 
40
-    println!("Number of ways: {}", ways);
41
-}
37
+println!("Number of ways: {}", ways);
42
 ```
38
 ```
43
 
39
 
44
 ## Example: Count ways in parallel
40
 ## Example: Count ways in parallel
47
 decoding the file in parallel:
43
 decoding the file in parallel:
48
 
44
 
49
 ```rust
45
 ```rust
50
-use osmpbf::*;
51
-
52
-fn main() {
53
-    let reader = ElementReader::from_path("tests/test.osm.pbf").unwrap();
54
-
55
-    // Count the ways
56
-    let ways = reader.par_map_reduce(
57
-        |element| {
58
-            match element {
59
-                Element::Way(_) => 1,
60
-                _ => 0,
61
-            }
62
-        },
63
-        || 0_u64,      // Zero is the identity value for addition
64
-        |a, b| a + b   // Sum the partial results
65
-    ).unwrap();
66
-
67
-    println!("Number of ways: {}", ways);
68
-}
46
+use osmpbf::{ElementReader, Element};
47
+
48
+let reader = ElementReader::from_path("tests/test.osm.pbf").unwrap();
49
+
50
+// Count the ways
51
+let ways = reader.par_map_reduce(
52
+    |element| {
53
+        match element {
54
+            Element::Way(_) => 1,
55
+            _ => 0,
56
+        }
57
+    },
58
+    || 0_u64,      // Zero is the identity value for addition
59
+    |a, b| a + b   // Sum the partial results
60
+).unwrap();
61
+
62
+println!("Number of ways: {}", ways);
69
 ```
63
 ```
70
 */
64
 */
71
 
65