Skip to content

Commit beb6af6

Browse files
authored
Merge pull request #1 from antoine-de/review
consume the nodes not to copy them all
2 parents f4bb7ad + 17cc64b commit beb6af6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/osm4routing/reader.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,11 @@ impl Reader {
108108
}
109109

110110

111-
fn nodes(&self) -> Vec<Node> {
111+
fn nodes(self) -> Vec<Node> {
112112
self.nodes
113-
.iter()
113+
.into_iter()
114114
.map(|(_, node)| node)
115115
.filter(|node| node.uses > 1)
116-
.map(|n| n.clone())
117116
.collect()
118117
}
119118

@@ -127,12 +126,13 @@ pub fn read(filename: &str) -> Result<(Vec<Node>, Vec<Edge>), String> {
127126
let mut r = Reader::new();
128127
try!(r.read(filename));
129128
r.count_nodes_uses();
130-
Ok((r.nodes(), r.edges()))
129+
let edges = r.edges();
130+
Ok((r.nodes(), edges))
131131
}
132132

133133
#[test]
134134
fn test_real_all() {
135-
let (nodes, ways) = read("src/osm4routing/test_data/minimal.osm.pbf");
135+
let (nodes, ways) = read("src/osm4routing/test_data/minimal.osm.pbf").unwrap();
136136
assert_eq!(2, nodes.len());
137137
assert_eq!(1, ways.len());
138138
}
@@ -188,7 +188,7 @@ fn test_split() {
188188
}
189189

190190
#[test]
191-
#[should_panic]
192191
fn test_wrong_file() {
193-
read("i hope you have no file name like this one");
192+
let r = read("i hope you have no file name like this one");
193+
assert!(r.is_err());
194194
}

0 commit comments

Comments
 (0)