[libgee] Fix default Traversable.stream implementation for Iterator<G>



commit c943a97fc67f82bf77f31117561134fec06404b4
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date:   Wed Aug 17 21:43:34 2011 +0100

    Fix default Traversable.stream implementation for Iterator<G>
    
    The implementation assumed in unfolding function that the stream  some
    value - however it might not be the case.

 gee/iterator.vala |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gee/iterator.vala b/gee/iterator.vala
index a52f257..b7d51af 100644
--- a/gee/iterator.vala
+++ b/gee/iterator.vala
@@ -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 ()) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]