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:
parent
63f6b6f81b
commit
95a24fa987
2 changed files with 21 additions and 18 deletions
|
|
@ -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());
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue