diff --git a/mm2src/mm2_io/src/fs.rs b/mm2src/mm2_io/src/fs.rs index 00838ae1cc..489b3bad8b 100644 --- a/mm2src/mm2_io/src/fs.rs +++ b/mm2src/mm2_io/src/fs.rs @@ -203,14 +203,13 @@ async fn filter_files_by_extension(dir_path: &Path, extension: &str) -> IoResult } /// Helper function to extract file names or stems based on the provided extraction function. -fn extract_file_identifiers(entries: Vec, extractor: F) -> Vec +fn extract_file_identifiers<'a, F>(entries: Vec, extractor: F) -> impl Iterator + 'a where - F: Fn(&Path) -> Option<&OsStr>, + F: Fn(&Path) -> Option<&OsStr> + 'a, { entries .into_iter() - .filter_map(|path| extractor(&path).and_then(OsStr::to_str).map(ToOwned::to_owned)) - .collect() + .filter_map(move |path| extractor(&path).and_then(OsStr::to_str).map(ToOwned::to_owned)) } /// Lists files by the specified extension from the given directory path. @@ -219,7 +218,7 @@ pub async fn list_files_by_extension( dir_path: &Path, extension: &str, include_extension: bool, -) -> IoResult> { +) -> IoResult> { let entries = filter_files_by_extension(dir_path, extension).await?; let extractor = if include_extension { Path::file_name diff --git a/mm2src/mm2_main/src/lp_wallet.rs b/mm2src/mm2_main/src/lp_wallet.rs index 0efc631643..559821a26a 100644 --- a/mm2src/mm2_main/src/lp_wallet.rs +++ b/mm2src/mm2_main/src/lp_wallet.rs @@ -538,7 +538,7 @@ impl From for GetWalletsError { /// Retrieves all created wallets and the currently activated wallet. pub async fn get_wallet_names_rpc(ctx: MmArc, _req: Json) -> MmResult { // We want to return wallet names in the same order for both native and wasm32 targets. - let wallets = read_all_wallet_names(&ctx).await?.into_iter().sorted().collect(); + let wallets = read_all_wallet_names(&ctx).await?.sorted().collect(); // Note: `ok_or` is used here on `Constructible>` to handle the case where the wallet name is not set. // `wallet_name` can be `None` in the case of no-login mode. let activated_wallet = ctx.wallet_name.ok_or(GetWalletsError::Internal( diff --git a/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs b/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs index 97a745facf..c873b2d5ff 100644 --- a/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs +++ b/mm2src/mm2_main/src/lp_wallet/mnemonics_storage.rs @@ -62,7 +62,7 @@ pub(super) async fn read_encrypted_passphrase_if_available(ctx: &MmArc) -> Walle }) } -pub(super) async fn read_all_wallet_names(ctx: &MmArc) -> WalletsStorageResult> { +pub(super) async fn read_all_wallet_names(ctx: &MmArc) -> WalletsStorageResult> { let wallet_names = list_files_by_extension(&ctx.db_root(), "dat", false) .await .mm_err(|e| WalletsStorageError::FsReadError(format!("Error reading wallets directory: {}", e)))?; diff --git a/mm2src/mm2_main/src/lp_wallet/mnemonics_wasm_db.rs b/mm2src/mm2_main/src/lp_wallet/mnemonics_wasm_db.rs index 06dd565ce5..a815bfcca1 100644 --- a/mm2src/mm2_main/src/lp_wallet/mnemonics_wasm_db.rs +++ b/mm2src/mm2_main/src/lp_wallet/mnemonics_wasm_db.rs @@ -145,7 +145,7 @@ pub(super) async fn read_encrypted_passphrase_if_available(ctx: &MmArc) -> Walle .transpose() } -pub(super) async fn read_all_wallet_names(ctx: &MmArc) -> WalletsDBResult> { +pub(super) async fn read_all_wallet_names(ctx: &MmArc) -> WalletsDBResult> { let wallets_ctx = WalletsContext::from_ctx(ctx).map_to_mm(WalletsDBError::Internal)?; let db = wallets_ctx.wallets_db().await?; @@ -153,7 +153,7 @@ pub(super) async fn read_all_wallet_names(ctx: &MmArc) -> WalletsDBResult().await?; let all_items = table.get_all_items().await?; - let wallet_names = all_items.into_iter().map(|(_, item)| item.wallet_name).collect(); + let wallet_names = all_items.into_iter().map(|(_, item)| item.wallet_name); Ok(wallet_names) }