Skip to content

Commit 7a52db5

Browse files
committed
Remove a mut vec
1 parent d2c9151 commit 7a52db5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/krate.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,9 @@ pub fn downloads(req: &mut Request) -> CargoResult<Response> {
10151015
WHERE date > $1
10161016
AND version_id = ANY($2)
10171017
ORDER BY date ASC")?;
1018-
let mut downloads = Vec::new();
1019-
for row in stmt.query(&[&cutoff_date, &ids])?.iter() {
1020-
let download: VersionDownload = Model::from_row(&row);
1021-
downloads.push(download.encodable());
1022-
}
1018+
let downloads = stmt.query(&[&cutoff_date, &ids])?.iter().map(|row| {
1019+
VersionDownload::from_row(&row).encodable()
1020+
}).collect::<Vec<_>>();
10231021

10241022
let stmt = tx.prepare("\
10251023
SELECT COALESCE(to_char(DATE(version_downloads.date), 'YYYY-MM-DD'), '') AS date,

0 commit comments

Comments
 (0)