(directory: T)
| 84 | } |
| 85 | |
| 86 | pub fn parse_directory<T>(directory: T) -> Result<Vec<File>> |
| 87 | where |
| 88 | T: Into<String>, |
| 89 | { |
| 90 | let regex = format!("{}/**/*.rs", directory.into()).replace("//", "/"); |
| 91 | let mut res = Vec::new(); |
| 92 | let context = || format!("Invalid glob regex: `{regex}`"); |
| 93 | for path in glob(®ex).with_context(context)?.filter_map(Result::ok) { |
| 94 | let modified = path_created(&path); |
| 95 | let file_path = path_to_str(&path).into(); |
| 96 | let functions = parse_file(&path) |
| 97 | .with_context(|| format!("Fail to parse file: `{}`", path.display()))?; |
| 98 | res.push(File { |
| 99 | path: file_path, |
| 100 | functions, |
| 101 | crate_name: "".into(), |
| 102 | modified, |
| 103 | }); |
| 104 | } |
| 105 | Ok(res) |
| 106 | } |
| 107 | |
| 108 | pub fn parse_workspace<T>(directory: T) -> Result<Workspace> |
| 109 | where |
no test coverage detected