added: `iter.empty`
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 13 May 2023 17:37:06 +0000 (12:37 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 13 May 2023 17:37:06 +0000 (12:37 -0500)
core/container/iter.onyx

index 80f04ed98865784789ddb4b8708de4fbf63f079f..5e37c928919e5b0a57341159bde025535a1795c1 100644 (file)
@@ -68,6 +68,19 @@ close :: (it: Iterator) {
     }
 }
 
+
+#doc """
+    Helper function to create an iterator of a type that does not produce an values.
+"""
+empty :: ($T: type_expr) -> Iterator(T) {
+    return .{
+        // CLEANUP: Fix the compiler bug that makes this not able to a closure.
+        next = #solidify ($T: type_expr, _: rawptr) -> (T, bool) {
+            return .{}, false;
+        } { T = T }
+    };
+}
+
 //
 // Implicit iterator creation
 //