Skip to content

Commit

Permalink
Iterator::Flatten#rewind returns iterator itself
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust authored and asterite committed Dec 23, 2016
1 parent 0dfd469 commit 352d5f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/std/iterator_spec.cr
Expand Up @@ -632,5 +632,12 @@ describe Iterator do
iter.next.should eq(7)
iter.next.should be_a(Iterator::Stop)
end

it "return iterator itself by rewind" do
iter = [1, [2, 3], 4].each.flatten

iter.to_a.should eq([1, 2, 3, 4])
iter.rewind.to_a.should eq([1, 2, 3, 4])
end
end
end
1 change: 1 addition & 0 deletions src/iterator.cr
Expand Up @@ -448,6 +448,7 @@ module Iterator(T)
@generators << @iterator
@stopped.each &.rewind
@stopped.clear
self
end

def self.element_type(element)
Expand Down

0 comments on commit 352d5f0

Please sign in to comment.