From 02efb796e3b875c8a4aa1adf8a3015cdd19796cd Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 13 May 2023 12:37:06 -0500 Subject: [PATCH] added: `iter.empty` --- core/container/iter.onyx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/container/iter.onyx b/core/container/iter.onyx index 80f04ed9..5e37c928 100644 --- a/core/container/iter.onyx +++ b/core/container/iter.onyx @@ -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 // -- 2.25.1