diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index 8687f0ba..70767c7e 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -36,16 +36,17 @@ pub struct StoreCollection { pub fn with_store) -> Result>( app: AppHandle, collection: State<'_, StoreCollection>, - path: PathBuf, + path: impl AsRef, f: F, ) -> Result { let mut stores = collection.stores.lock().expect("mutex poisoned"); - if !stores.contains_key(&path) { + let path = path.as_ref(); + if !stores.contains_key(path) { if collection.frozen { - return Err(Error::NotFound(path)); + return Err(Error::NotFound(path.to_path_buf())); } - let mut store = StoreBuilder::new(app, path.clone()).build(); + let mut store = StoreBuilder::new(app, path.to_path_buf()).build(); // ignore loading errors, just use the default if let Err(err) = store.load() { warn!( @@ -53,11 +54,11 @@ pub fn with_store) -> Result>( path, err ); } - stores.insert(path.clone(), store); + stores.insert(path.to_path_buf(), store); } f(stores - .get_mut(&path) + .get_mut(path) .expect("failed to retrieve store. This is a bug!")) }