turbo
0f7ef21e - chore(path): make path reading api more rusty (#9103)

Commit
1 year ago
chore(path): make path reading api more rusty (#9103) ### Description Remove `read_existing_to_string_or` in favor of `read_existing_to_string` to consolidate on the more Rust-y API for reading a path to a file. `read_existing_to_string_or` is an awkward API due: - It conflates two outcomes: The file not existing and the file existing with the contents of the default - The default is provided as `Result<impl Into<String>, io::Error>`. `impl Into<String>` was chosen so unnecessary work could be avoided. This is limiting compared to `FnOnce() -> String`. - It prevents us from using the battle tested `Option` API The benefits of not conflating the two outcomes is best displayed when trying to read a config file. Instead of defaulting having a default of `{}` and then parsing it as JSON we can skip the parse and just use `ConfigurationOptions::default()` ### Testing Instructions Existing unit tests + 👀
Parents
Loading