Skip to content

Commit

Permalink
size_hint was added
Browse files Browse the repository at this point in the history
  • Loading branch information
inv2004 committed Mar 14, 2018
1 parent bd35ff0 commit e594312
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 0 deletions.
141 changes: 141 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ mod old_slice {
impl<'a> Iterator for Iter<'a> {
type Item = SRef<'a>;

fn size_hint(&self) -> (usize, Option<usize>) {
self.a.size_hint()
}

fn next(&mut self) -> Option<Self::Item> {
let a = self.a.next();
let b = self.b.next();
Expand Down Expand Up @@ -94,6 +98,10 @@ mod new_slice {
impl<'a> Iterator for Iter<'a> {
type Item = SRef<'a>;

fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}

fn next(&mut self) -> Option<Self::Item> {
if let Some((((a,b),c),d)) = self.0.next() {
Some(SRef{a, b, c, d})
Expand Down Expand Up @@ -132,6 +140,10 @@ mod new2_slice {
impl<'a> Iterator for Iter<'a> {
type Item = SRef<'a>;

fn size_hint(&self) -> (usize, Option<usize>) {
(self.len, Some(self.len))
}

fn next(&mut self) -> Option<Self::Item> {
if self.i < self.len {
let r = SRef{
Expand Down

0 comments on commit e594312

Please sign in to comment.