(path: impl AsRef<Path>)
| 30 | struct Suggestion(&'static str); |
| 31 | |
| 32 | fn parse_config(path: impl AsRef<Path>) -> Result<Config, Report<ParseConfigError>> { |
| 33 | let path = path.as_ref(); |
| 34 | |
| 35 | let content = fs::read_to_string(path) |
| 36 | .change_context(ParseConfigError::new()) |
| 37 | .attach_opaque(Suggestion("use a file you can read next time!")) |
| 38 | .attach_with(|| format!("could not read file {}", path.display()))?; |
| 39 | |
| 40 | Ok(content) |
| 41 | } |
| 42 | |
| 43 | fn main() { |
| 44 | if let Err(report) = parse_config("config.json") { |
no test coverage detected