Function
rewrite_json
(path: &Path, edit: impl FnOnce(&mut Value))
Source from the content-addressed store, hash-verified
| 387 | } |
| 388 | |
| 389 | fn rewrite_json(path: &Path, edit: impl FnOnce(&mut Value)) -> io::Result<()> { |
| 390 | let mut value: Value = serde_json::from_str(&fs::read_to_string(path)?)?; |
| 391 | edit(&mut value); |
| 392 | fs::write(path, serde_json::to_string_pretty(&value)?) |
| 393 | } |
| 394 | |
| 395 | fn io_other(err: impl std::fmt::Display) -> io::Error { |
| 396 | io::Error::other(err.to_string()) |
Tested by
no test coverage detected