瀏覽代碼

Fix clippy warnings `needless_doctest_main`

Johannes Hofmann 6 年之前
父節點
當前提交
20209a75e4
共有 1 個文件被更改,包括 28 次插入34 次删除
  1. 28
    34
      src/lib.rs

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

@@ -10,7 +10,7 @@ Add this to your `Cargo.toml`:
10 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 15
 ```rust
16 16
 extern crate osmpbf;
@@ -22,23 +22,19 @@ Here's a simple example that counts all the OpenStreetMap way elements in a
22 22
 file:
23 23
 
24 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 40
 ## Example: Count ways in parallel
@@ -47,25 +43,23 @@ In this second example, we also count the ways but make use of all cores by
47 43
 decoding the file in parallel:
48 44
 
49 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