Return `None` if there are no items

master
Paul Woolcock 6 years ago
parent b4cbcfa1a7
commit 68f8766aff
  1. 3
      src/entities/pageiter.rs

@ -55,6 +55,9 @@ impl<'a, T: Clone+ for<'de> Deserialize<'de>> Iterator for PageIter<'a, T> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
if self.use_initial { if self.use_initial {
if self.page.initial_items.is_empty() {
return None;
}
let idx = self.cur_idx; let idx = self.cur_idx;
if self.cur_idx == self.page.initial_items.len() - 1 { if self.cur_idx == self.page.initial_items.len() - 1 {
self.cur_idx = 0; self.cur_idx = 0;

Loading…
Cancel
Save