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
41
42
43
44
45
46
47
48
49
use std::path::PathBuf;
use std::collections::HashMap;
#[derive(Clone, Debug)]
pub struct Config
{
pub supported_file_extensions: Vec<String>,
pub test_paths: Vec<PathBuf>,
pub constants: HashMap<String, String>,
}
impl Config
{
pub fn add_extension<S>(&mut self, ext: S) where S: Into<String> {
self.supported_file_extensions.push(ext.into())
}
pub fn add_search_path<P>(&mut self, path: P) where P: Into<String> {
self.test_paths.push(PathBuf::from(path.into()));
}
pub fn is_extension_supported(&self, extension: &str) -> bool {
self.supported_file_extensions.iter().
find(|ext| &ext[..] == extension).is_some()
}
}
impl Default for Config
{
fn default() -> Self {
Config {
supported_file_extensions: Vec::new(),
test_paths: Vec::new(),
constants: HashMap::new(),
}
}
}