rust-cli/confy

allow user define a custom value if the file doesn't exist or is empty

asuper0 opened this issue · 2 comments

pub fn load_path_or_else<T, F>(
    path: impl AsRef<Path>,
    op: F
) -> Result<T, ConfyError>
where
    T: DeserializeOwned + Serialize,
    F: FnOnce() -> T,
{ }

Add the function so that user can pass a closure, which could return a custom value if the file doesn't exist or is empty.

could solve #85

closed by #98.