From c8e0215e1cf234084586e0137672c433fa2a23da Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 5 Aug 2025 18:27:42 +0300 Subject: [PATCH] use vector to keep the order from the arguments list --- src/feed.rs | 5 ++--- src/format.rs | 2 +- src/main.rs | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/feed.rs b/src/feed.rs index 95cae11..26fa2e3 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -1,5 +1,4 @@ use crate::format; -use std::collections::HashSet; use url::Url; /// Export crawl index to the RSS file @@ -7,7 +6,7 @@ pub struct Feed { description: Option, link: Option, title: String, - trackers: Option>, + trackers: Option>, } impl Feed { @@ -15,7 +14,7 @@ impl Feed { title: String, description: Option, link: Option, - trackers: Option>, + trackers: Option>, ) -> Self { Self { description: description.map(escape), diff --git a/src/format.rs b/src/format.rs index b3b0d11..6016590 100644 --- a/src/format.rs +++ b/src/format.rs @@ -16,7 +16,7 @@ pub fn bytes(value: u64) -> String { } } -pub fn magnet(info_hash: &str, trackers: Option<&std::collections::HashSet>) -> String { +pub fn magnet(info_hash: &str, trackers: Option<&Vec>) -> String { let mut b = if info_hash.len() == 40 { format!("magnet:?xt=urn:btih:{info_hash}") } else { diff --git a/src/main.rs b/src/main.rs index e1d5e89..383e634 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,6 @@ use rocket::{ serde::Serialize, }; use rocket_dyn_templates::{Template, context}; -use std::collections::HashSet; use storage::{Order, Sort, Storage, Torrent}; use url::Url; @@ -27,7 +26,8 @@ pub struct Meta { pub format_time: String, pub stats: Option, pub title: String, - pub trackers: Option>, + /// * use vector to keep the order from the arguments list + pub trackers: Option>, } #[get("/?")] @@ -99,7 +99,7 @@ fn rocket() -> _ { config.title.clone(), config.description.clone(), config.link.clone(), - config.tracker.clone().map(|u| u.into_iter().collect()), + config.tracker.clone(), ); let storage = Storage::init(config.storage, config.list_limit, config.capacity).unwrap(); // @TODO handle rocket::build() @@ -117,7 +117,7 @@ fn rocket() -> _ { format_time: config.format_time, stats: config.stats, title: config.title, - trackers: config.tracker.map(|u| u.into_iter().collect()), + trackers: config.tracker, }) .mount("/", routes![index, rss]) }