From faa4f713c86cd82647c4e0ec92c0b7f03b205ba5 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Tue, 11 May 2021 22:11:35 +0200 Subject: [PATCH] [#45] Fixed clippy errors --- src/fej/ivago/pickup_time.rs | 5 +---- src/populate_ivago.rs | 7 +++++-- src/server/main.rs | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/fej/ivago/pickup_time.rs b/src/fej/ivago/pickup_time.rs index f70cbcf..19031fb 100644 --- a/src/fej/ivago/pickup_time.rs +++ b/src/fej/ivago/pickup_time.rs @@ -16,10 +16,7 @@ impl PickupTime { /// * `date` - Date of pickup time /// * `label` - Type of trash pub fn new(date: BasicDate, label: String) -> PickupTime { - PickupTime { - date: date, - label: label, - } + PickupTime { date, label } } } diff --git a/src/populate_ivago.rs b/src/populate_ivago.rs index 9dfc876..0886551 100644 --- a/src/populate_ivago.rs +++ b/src/populate_ivago.rs @@ -8,12 +8,15 @@ fn main() { let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); let db_conn = PgConnection::establish(&database_url) - .expect(&format!("Error connecting to {}", database_url)); + .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)); // Doing this linearly is good enough I'd say for c in ABC.chars() { if let Ok(streets) = search_streets(&c.to_string()) { - insert_into(ivago_streets).values(streets).execute(&db_conn); + insert_into(ivago_streets) + .values(streets) + .execute(&db_conn) + .expect("Failed to insert rows."); } } } diff --git a/src/server/main.rs b/src/server/main.rs index 2a5bd2f..bfe4fef 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -23,9 +23,9 @@ use rocket_contrib::databases::diesel; #[cfg(feature = "frontend")] use rocket_contrib::serve::StaticFiles; -pub struct CORS; +pub struct Cors; -impl Fairing for CORS { +impl Fairing for Cors { fn info(&self) -> Info { Info { name: "Add CORS headers to responses", @@ -63,8 +63,9 @@ fn run_db_migrations(rocket: Rocket) -> Result { fn rocket() -> rocket::Rocket { // This needs to be muted for the frontend feature + #[allow(unused_mut)] let mut rocket = rocket::ignite() - .attach(CORS) + .attach(Cors) .attach(FejDbConn::fairing()) .attach(AdHoc::on_attach("Database Migrations", run_db_migrations)) .mount("/api/ivago", routes::ivago()) // /api being hardcoded is temporary