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
use std::io::Read;
pub trait FileInterface {
fn extract(&mut self) -> Vec<String> {
let mut buffer = String::new();
self.open_file()
.read_to_string(&mut buffer)
.expect("IOError");
buffer.split('\n').map(|s: &str| s.to_string()).collect()
}
fn filepath(&self) -> Box<std::path::Path>;
fn open_file(&self) -> std::fs::File {
match std::fs::File::open(self.filepath()) {
Ok(file) => file,
Err(e) => panic!("File Error: File Not Found \n{}", e),
}
}
}