1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::cmp::PartialEq;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use super::Node;
pub mod coordinates;
impl<'a> PartialEq for Node {
fn eq(&self, other: &Node) -> bool {
self.hash == other.hash
}
}
fn get_node_names(path: &str) -> Result<Vec<String>, io::Error> {
let mut file = File::open(path)?;
let mut contents = String::new();
let mut names: Vec<String> = Vec::new();
file.read_to_string(&mut contents)?;
let split = contents.split('\n');
for value in split {
names.push(value.to_string());
}
Ok(names)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_node_names_fail() {
let res = get_node_names("invalid path");
assert_eq!(res.is_err(), true);
}
}