diff options
author | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-03-05 17:34:05 +0000 |
---|---|---|
committer | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-03-05 17:34:05 +0000 |
commit | 0433528a7c432b1e7784bd133353c5fc2d1cc8a1 (patch) | |
tree | c1e358530fa26fce611905e2211dc6fd122fcc65 | |
parent | Update Cargo.lock (diff) | |
download | miniserve-0433528a7c432b1e7784bd133353c5fc2d1cc8a1.tar.gz miniserve-0433528a7c432b1e7784bd133353c5fc2d1cc8a1.zip |
Refactored if/let for sorting methods
-rw-r--r-- | src/listing.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/listing.rs b/src/listing.rs index e86cc04..57bef17 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -134,13 +134,11 @@ pub fn directory_listing<S>( let is_root = base.parent().is_none() || req.path() == random_route; let page_parent = base.parent().map(|p| p.display().to_string()); - let mut sort_method: Option<SortingMethod> = None; - let mut sort_order: Option<SortingOrder> = None; - - if let Ok(query) = Query::<QueryParameters>::extract(req) { - sort_method = query.sort.clone(); - sort_order = query.order.clone(); - } + let (sort_method, sort_order) = if let Ok(query) = Query::<QueryParameters>::extract(req) { + (query.sort.clone(), query.order.clone()) + } else { + (None, None) + }; let mut entries: Vec<Entry> = Vec::new(); |