From d979873c984f1a1107308b6338e9e6070b7a07ed Mon Sep 17 00:00:00 2001 From: Mike Dallas Date: Thu, 3 Nov 2022 21:26:30 +0000 Subject: [PATCH] rustfmt --- src/download.rs | 13 +++---------- src/main.rs | 20 ++++++++++++-------- src/structures.rs | 2 +- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/download.rs b/src/download.rs index ad800e7..d9d7ff9 100644 --- a/src/download.rs +++ b/src/download.rs @@ -501,7 +501,6 @@ impl<'a> Downloader<'a> { /// Check if a particular URL contains supported media. async fn get_media(&self, data: &PostData) -> Result, GertError> { - let original = data.url.as_ref().unwrap(); let mut media: Vec = Vec::new(); @@ -572,22 +571,16 @@ impl<'a> Downloader<'a> { // collect all the URLs for the images in the album let mut image_urls = Vec::new(); for item in gallery.items.iter() { - - let mut ext = JPG_EXTENSION; if let Some(metadata) = media_metadata { if let Some(media) = metadata.get(&item.media_id) { - ext = media.m.split('/').last().unwrap(); + ext = media.m.split('/').last().unwrap(); } } - - // extract the media ID from each gallery item and reconstruct the image URL - let image_url = format!( - "https://{}/{}.{}", - REDDIT_IMAGE_SUBDOMAIN, item.media_id, ext - ); + let image_url = + format!("https://{}/{}.{}", REDDIT_IMAGE_SUBDOMAIN, item.media_id, ext); image_urls.push(image_url); } let supported_media = SupportedMedia { diff --git a/src/main.rs b/src/main.rs index e0bdaec..098d48b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,20 +128,24 @@ async fn main() -> Result<(), GertError> { let limit = match matches.value_of("limit").unwrap().parse::() { Ok(limit) => limit, Err(_) => { - let err = clap::Error::with_description("Limit must be a number", clap::ErrorKind::InvalidValue); + let err = clap::Error::with_description( + "Limit must be a number", + clap::ErrorKind::InvalidValue, + ); err.exit(); } }; let period = matches.value_of("period"); let feed = matches.value_of("feed").unwrap(); let pattern = match matches.value_of("match") { - Some(pattern) => { - match regex::Regex::new(pattern) { - Ok(reg) => reg, - Err(_) => { - let err = clap::Error::with_description("Invalid regex pattern", clap::ErrorKind::InvalidValue); - err.exit(); - } + Some(pattern) => match regex::Regex::new(pattern) { + Ok(reg) => reg, + Err(_) => { + let err = clap::Error::with_description( + "Invalid regex pattern", + clap::ErrorKind::InvalidValue, + ); + err.exit(); } }, None => regex::Regex::new(".*").unwrap(), diff --git a/src/structures.rs b/src/structures.rs index 9d1bd15..0386465 100644 --- a/src/structures.rs +++ b/src/structures.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; -use std::{ops::Add, collections::HashMap}; +use std::{collections::HashMap, ops::Add}; /// Data structure that represents a user's info #[derive(Debug, Serialize, Deserialize)]