Skip to content

Commit d2c9151

Browse files
committed
Remove a mut vec
1 parent 0a7ac80 commit d2c9151

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/version.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,9 @@ pub fn downloads(req: &mut Request) -> CargoResult<Response> {
307307
let stmt = tx.prepare("SELECT * FROM version_downloads
308308
WHERE date > $1 AND version_id = $2
309309
ORDER BY date ASC")?;
310-
let mut downloads = Vec::new();
311-
for row in stmt.query(&[&cutoff_date, &version.id])?.iter() {
312-
let download: VersionDownload = Model::from_row(&row);
313-
downloads.push(download.encodable());
314-
}
310+
let downloads = stmt.query(&[&cutoff_date, &version.id])?.iter().map(|row| {
311+
VersionDownload::from_row(&row).encodable()
312+
}).collect();
315313

316314
#[derive(RustcEncodable)]
317315
struct R { version_downloads: Vec<EncodableVersionDownload> }

0 commit comments

Comments
 (0)