chore: evaluate error context lazily (#447)

This commit is contained in:
hybo
2023-03-16 17:06:52 +08:00
committed by GitHub
parent 198109cd43
commit 9cc47678a2
2 changed files with 14 additions and 11 deletions

View File

@@ -138,9 +138,9 @@ impl IProfiles {
let path = dirs::app_profiles_dir()?.join(&file);
fs::File::create(path)
.context(format!("failed to create file \"{}\"", file))?
.with_context(|| format!("failed to create file \"{}\"", file))?
.write(file_data.as_bytes())
.context(format!("failed to write to file \"{}\"", file))?;
.with_context(|| format!("failed to write to file \"{}\"", file))?;
}
if self.items.is_none() {
@@ -207,9 +207,9 @@ impl IProfiles {
let path = dirs::app_profiles_dir()?.join(&file);
fs::File::create(path)
.context(format!("failed to create file \"{}\"", file))?
.with_context(|| format!("failed to create file \"{}\"", file))?
.write(file_data.as_bytes())
.context(format!("failed to write to file \"{}\"", file))?;
.with_context(|| format!("failed to write to file \"{}\"", file))?;
}
break;