| 548 | type Item = RepoTopic; |
| 549 | |
| 550 | fn next(&mut self) -> Option<Self::Item> { |
| 551 | log::debug!("next() with {} stack elements", self.stack.len()); |
| 552 | |
| 553 | while !self.stack.is_empty() { |
| 554 | match self.stack.pop() { |
| 555 | Some(topic_child) => { |
| 556 | if self.seen.contains(&topic_child) { |
| 557 | log::debug!("topic already seen, skipping: {}", topic_child.id); |
| 558 | continue; |
| 559 | } |
| 560 | self.seen.insert(topic_child.clone()); |
| 561 | |
| 562 | let topic_id = &topic_child.id; |
| 563 | |
| 564 | if let Some(topic) = self.client.fetch_topic(self.repo_id, topic_id) { |
| 565 | for child in &topic.children { |
| 566 | if child.kind != Kind::Topic { |
| 567 | break; |
| 568 | } |
| 569 | self.stack.push(child.clone()); |
| 570 | } |
| 571 | log::debug!("yielding topic {}", topic_child.id); |
| 572 | return Some(topic); |
| 573 | }; |
| 574 | } |
| 575 | |
| 576 | None => { |
| 577 | log::error!("expected a topic, continuing"); |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | None |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | impl<'c> TopicDownsetIter<'c> { |