Split up a couple large functions

This commit is contained in:
Igor Katson 2024-02-28 20:27:45 +00:00
parent 340d54eafa
commit 5488e1d40f
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 88 additions and 71 deletions

View file

@ -49,7 +49,10 @@ pub struct TorrentMetaV1<BufType> {
impl<BufType> TorrentMetaV1<BufType> {
pub fn iter_announce(&self) -> impl Iterator<Item = &BufType> {
once(&self.announce).chain(self.announce_list.iter().flatten())
if self.announce_list.iter().flatten().next().is_some() {
return itertools::Either::Left(self.announce_list.iter().flatten());
}
itertools::Either::Right(once(&self.announce))
}
}