refactor: use Cow<str> for errors

since some errors are just string literals;
this lets us avoid allocating a new string
This commit is contained in:
electria 2026-08-25 09:37:00 -07:00
commit 95a24fa987
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
2 changed files with 21 additions and 18 deletions

View file

@ -34,7 +34,7 @@ fn load_image_impl(path: impl AsRef<Path>) -> ImageResult<RgbaImage> {
Ok(decoded_image.into_rgba8())
}
pub async fn pick_image() -> Result<PathBuf, String> {
pub async fn pick_image() -> Result<PathBuf, Cow<'static, str>> {
let Some(filehandle) = AsyncFileDialog::new()
.add_filter(
"image",
@ -52,7 +52,7 @@ pub async fn pick_image() -> Result<PathBuf, String> {
Ok(filehandle.path().to_owned())
}
pub async fn pick_save_path() -> Result<PathBuf, String> {
pub async fn pick_save_path() -> Result<PathBuf, Cow<'static, str>> {
let Some(filehandle) = AsyncFileDialog::new().save_file().await else {
return Err("no path to save provided".into());
};