Fix default Traversable.stream implementation for Iterator<G>
authorMaciej Piechotka <uzytkownik2@gmail.com>
Wed, 17 Aug 2011 20:43:34 +0000 (21:43 +0100)
committerMaciej Piechotka <uzytkownik2@gmail.com>
Wed, 17 Aug 2011 20:43:34 +0000 (21:43 +0100)
The implementation assumed in unfolding function that the stream  some
value - however it might not be the case.

gee/iterator.vala

index a52f257..b7d51af 100644 (file)
@@ -115,8 +115,9 @@ public interface Gee.Iterator<G> : Object, Traversable<G> {
                        assert_not_reached ();
                }
                return unfold<A> (() => {
-                       Lazy<A>? val;
-                       str = f (Traversable.Stream.YIELD, null, out val);
+                       Lazy<A>? val = null;
+                       if (str != Traversable.Stream.CONTINUE)
+                               str = f (Traversable.Stream.YIELD, null, out val);
                        while (str == Traversable.Stream.CONTINUE) {
                                if (need_next) {
                                        if (!self.next ()) {