From b9bce0c426ab258f2c5891ac7eecd944f749e27c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 1 Aug 2018 14:29:50 +0200 Subject: Run rustfmt on project. --- src/utils/mod.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/utils/mod.rs') diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 5392224..ad6cff1 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -12,10 +12,10 @@ pub fn init_db_pool<'a>(dburl: &'a str) -> Pool { r2d2::Pool::builder().build(manager).expect("db pool") } -use std::ops::Deref; use rocket::http::Status; use rocket::request::{self, FlashMessage, FromRequest}; -use rocket::{Request, State, Outcome}; +use rocket::{Outcome, Request, State}; +use std::ops::Deref; // Connection request guard type: a wrapper around an r2d2 pooled connection. pub struct DbConn(pub r2d2::PooledConnection>); @@ -30,7 +30,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for DbConn { let pool = request.guard::>()?; match pool.get() { Ok(conn) => Outcome::Success(DbConn(conn)), - Err(_) => Outcome::Failure((Status::ServiceUnavailable, ())) + Err(_) => Outcome::Failure((Status::ServiceUnavailable, ())), } } } @@ -49,7 +49,7 @@ impl Deref for DbConn { pub struct Page { pub title: String, pub flash: Option, - pub content: T + pub content: T, } macro_rules! implement_responder_for { @@ -59,14 +59,17 @@ macro_rules! implement_responder_for { // like this: `$template_type<'a>` // So it will have to be passed in to the argument at // the macro incovation instead. - ($template_type:ty) => ( + ($template_type:ty) => { impl<'a> ::rocket::response::Responder<'a> for ::utils::Page<$template_type> { - fn respond_to(self, _: &::rocket::Request) -> Result<::rocket::Response<'static>, ::rocket::http::Status> { + fn respond_to( + self, + _: &::rocket::Request, + ) -> Result<::rocket::Response<'static>, ::rocket::http::Status> { ::rocket::Response::build() .header(::rocket::http::ContentType::HTML) .sized_body(::std::io::Cursor::new(format!("{}", &self))) .ok() } } - ) + }; } -- cgit v1.2.3