Skip to content

Commit

Permalink
Remove examples/data-list-view's KeyIter type
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Dec 29, 2023
1 parent 3f91d3a commit 32dc804
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions examples/data-list-view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,6 @@ impl_scope! {
}
}

// Once RPITIT is stable we can replace this with range + map
struct KeyIter {
start: usize,
end: usize,
}
impl Iterator for KeyIter {
type Item = usize;
fn next(&mut self) -> Option<Self::Item> {
let mut item = None;
if self.start < self.end {
item = Some(self.start);
self.start += 1;
}
item
}
fn size_hint(&self) -> (usize, Option<usize>) {
let len = self.end.saturating_sub(self.start);
(len, Some(len))
}
}

impl SharedData for Data {
type Key = usize;
type Item = Item;
Expand All @@ -179,11 +158,10 @@ impl ListData for Data {
self.len
}

fn iter_from(&self, start: usize, limit: usize) -> KeyIter {
KeyIter {
start: start.min(self.len),
end: (start + limit).min(self.len),
}
fn iter_from(&self, start: usize, limit: usize) -> impl Iterator<Item = usize> {
let start = start.min(self.len);
let end = (start + limit).min(self.len);
(start..end).into_iter()
}
}

Expand Down

0 comments on commit 32dc804

Please sign in to comment.