diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-09-20 16:25:49 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-09-20 16:25:49 +0800 |
| commit | 648a70110894bc5d79c65c2e4775970ddc460c0f (patch) | |
| tree | 2cf0007f23a2da52e2596013fd9b26f622ef2812 /crates/utils | |
| parent | 1fbdf2882be1b2b84cb9246866dabc0d40cad099 (diff) | |
Add exist function to ConfigFile trait
Diffstat (limited to 'crates/utils')
| -rw-r--r-- | crates/utils/cfg_file/src/config.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/utils/cfg_file/src/config.rs b/crates/utils/cfg_file/src/config.rs index 8d97bf0..2333ab7 100644 --- a/crates/utils/cfg_file/src/config.rs +++ b/crates/utils/cfg_file/src/config.rs @@ -193,4 +193,15 @@ pub trait ConfigFile: Serialize + for<'a> Deserialize<'a> + Default { eprintln!("Failed to write file {}: {}", path.display(), e); } } + + /// Check if the file returned by `default_path` exists + fn exist() -> bool + where + Self: Sized + Send + Sync, + { + let Ok(path) = Self::default_path() else { + return false; + }; + path.exists() + } } |
