From ea47c33e5ac566d1dad9868e4bd1b686126da695 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 8 Sep 2025 22:16:59 +0300 Subject: [PATCH] add nothing text on empty result --- src/main.rs | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index ef2a654..244c76f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -279,23 +279,27 @@ fn list( b.push("## Recent\n".into()); - for torrent in torrents { - let i: TorrentMetaV1Owned = torrent_from_bytes(&torrent.bytes)?; - b.push(format!( - "=> /{} {}", - i.info_hash.as_string(), - i.info - .name - .as_ref() - .map(|n| n.to_string()) - .unwrap_or_default() - )); - b.push(format!( - "{} • {} • {}\n", - torrent.time.format(&config.format_date), - format::total(&i), - format::files(&i), - )) + if torrents.is_empty() { + b.push("Nothing.\n".into()) + } else { + for torrent in torrents { + let i: TorrentMetaV1Owned = torrent_from_bytes(&torrent.bytes)?; + b.push(format!( + "=> /{} {}", + i.info_hash.as_string(), + i.info + .name + .as_ref() + .map(|n| n.to_string()) + .unwrap_or_default() + )); + b.push(format!( + "{} • {} • {}\n", + torrent.time.format(&config.format_date), + format::total(&i), + format::files(&i), + )) + } } b.push("## Navigation\n".into());