Skip to content

Commit e868ba2

Browse files
committed
rusty iter
1 parent 741fb64 commit e868ba2

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

core/src/databases/database.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,30 @@ impl Database {
5656
.list_databases_tables(&project, &self.data_source_id, &self.database_id, None)
5757
.await?;
5858

59-
let mut table_rows_futures = Vec::new();
60-
61-
for table in &tables {
62-
let store_ref = &store;
63-
let project_ref = &project;
64-
let data_source_id = &self.data_source_id;
65-
let database_id = &self.database_id;
66-
let table_id = table.table_id().to_string();
67-
68-
let rows_future = async move {
69-
store_ref
70-
.list_database_rows(
71-
project_ref,
72-
data_source_id,
73-
database_id,
74-
&table_id,
75-
None,
76-
)
77-
.await
78-
};
79-
80-
table_rows_futures.push(rows_future);
81-
}
59+
let table_rows_futures = tables
60+
.iter()
61+
.map(|table| {
62+
let store_ref = &store;
63+
let project_ref = &project;
64+
let data_source_id = &self.data_source_id;
65+
let database_id = &self.database_id;
66+
let table_id = table.table_id().to_string();
67+
68+
let rows_future = async move {
69+
store_ref
70+
.list_database_rows(
71+
project_ref,
72+
data_source_id,
73+
database_id,
74+
&table_id,
75+
None,
76+
)
77+
.await
78+
};
79+
80+
rows_future
81+
})
82+
.collect::<Vec<_>>();
8283

8384
// Now, we concurrently wait for all futures to complete.
8485
let results: Vec<_> = futures::future::join_all(table_rows_futures).await;

0 commit comments

Comments
 (0)