From c3a7d73643a14bea4ae3f45a78fe68850f289982 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Tue, 2 Jun 2020 00:05:19 +0200 Subject: [PATCH] refactor: minor syntax improvements --- src/gzip.rs | 2 +- src/staticfiles.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gzip.rs b/src/gzip.rs index 2f43048..737c72a 100644 --- a/src/gzip.rs +++ b/src/gzip.rs @@ -20,7 +20,7 @@ impl AfterMiddleware for GzipMiddleware { if enable_gz && accept_gz { let compressed_bytes = resp.body.as_mut().map(|b| { - let mut encoder = GzEncoder::new(Vec::new(), Compression::fast()); + let mut encoder = GzEncoder::new(vec![], Compression::fast()); { let _ = b.write_body(&mut encoder); } diff --git a/src/staticfiles.rs b/src/staticfiles.rs index 2eba414..ba32bfc 100644 --- a/src/staticfiles.rs +++ b/src/staticfiles.rs @@ -31,7 +31,7 @@ impl StaticFiles { /// Handle static files for current `StaticFiles` middleware. pub fn handle(&self) -> Chain { // Check the root directory - let root_dir = match helpers::get_valid_dirpath(&self.opts.root_dir) { + let root_dir = &match helpers::get_valid_dirpath(&self.opts.root_dir) { Err(e) => { error!("{}", e); std::process::exit(1) @@ -40,7 +40,7 @@ impl StaticFiles { }; // Check the assets directory - let assets_dir = match helpers::get_valid_dirpath(&self.opts.assets_dir) { + let assets_dir = &match helpers::get_valid_dirpath(&self.opts.assets_dir) { Err(e) => { error!("{}", e); std::process::exit(1) @@ -49,7 +49,7 @@ impl StaticFiles { }; // Get the assets directory name - let assets_dirname = match helpers::get_dirname(&assets_dir) { + let assets_dirname = &match helpers::get_dirname(assets_dir) { Err(e) => { error!("{}", e); std::process::exit(1) @@ -59,8 +59,7 @@ impl StaticFiles { // Define middleware chain let mut chain = Chain::new( - Staticfile::new(&root_dir, &assets_dir) - .expect("Directory to serve files was not found"), + Staticfile::new(root_dir, assets_dir).expect("Directory to serve files was not found"), ); let one_day = Duration::new(60 * 60 * 24, 0); let one_year = Duration::new(60 * 60 * 24 * 365, 0); -- libgit2 1.7.2