From 0fcf8fe5234546873d39ca0289711acd310221d4 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 17 Mar 2021 03:09:21 +0100 Subject: [PATCH] Remove duplicate code, clippy fixes --- src/crawl.rs | 4 ++-- src/lib.rs | 4 ++-- src/main.rs | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/crawl.rs b/src/crawl.rs index 063d1e0..c907162 100644 --- a/src/crawl.rs +++ b/src/crawl.rs @@ -38,7 +38,7 @@ pub async fn crawl( Err(e) => { failed_instances += 1; eprintln!("Failed to crawl {}: {}", current_instance.domain, e) - }, + } } } @@ -89,7 +89,7 @@ async fn fetch_instance_details(domain: &str) -> Result let linked_instances = site_info .federated_instances .map(|f| f.linked) - .unwrap_or(vec![]); + .unwrap_or_default(); Ok(InstanceDetails { domain: domain.to_owned(), name: site_info.site_view.site.name, diff --git a/src/lib.rs b/src/lib.rs index 0463f96..bf7e6e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,5 +5,5 @@ pub mod federated_instances; pub mod node_info; pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(10); -pub const DEFAULT_START_INSTANCES: &'static str = "lemmy.ml"; -pub const DEFAULT_MAX_CRAWL_DEPTH: &'static str = "1"; +pub const DEFAULT_START_INSTANCES: &str = "lemmy.ml"; +pub const DEFAULT_MAX_CRAWL_DEPTH: &str = "1"; diff --git a/src/main.rs b/src/main.rs index 4c16c2b..7bd0f93 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,10 +18,10 @@ pub async fn main() -> Result<(), Error> { .takes_value(true), ) .get_matches(); - let trusted_instances: Vec = matches + let start_instances: Vec = matches .value_of("start-instances") .unwrap_or(DEFAULT_START_INSTANCES) - .split(",") + .split(',') .map(|s| s.to_string()) .collect(); let max_crawl_depth: i32 = matches @@ -29,8 +29,6 @@ pub async fn main() -> Result<(), Error> { .unwrap_or(DEFAULT_MAX_CRAWL_DEPTH) .parse()?; - let start_instances = trusted_instances.iter().map(|s| s.to_string()).collect(); - eprintln!("Crawling..."); let (instance_details, failed_instances) = crawl(start_instances, max_crawl_depth).await?; let total_stats = aggregate(instance_details, failed_instances);