From 32dc804476abde97d84e99d3855693e9636a4f85 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Fri, 29 Dec 2023 10:05:15 +0000 Subject: [PATCH] Remove examples/data-list-view's KeyIter type --- examples/data-list-view.rs | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/examples/data-list-view.rs b/examples/data-list-view.rs index 42c6c88b9..8d5959d45 100644 --- a/examples/data-list-view.rs +++ b/examples/data-list-view.rs @@ -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 { - let mut item = None; - if self.start < self.end { - item = Some(self.start); - self.start += 1; - } - item - } - fn size_hint(&self) -> (usize, Option) { - let len = self.end.saturating_sub(self.start); - (len, Some(len)) - } -} - impl SharedData for Data { type Key = usize; type Item = Item; @@ -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 { + let start = start.min(self.len); + let end = (start + limit).min(self.len); + (start..end).into_iter() } }