From: Brendan Hansen Date: Sat, 13 May 2023 17:37:06 +0000 (-0500) Subject: added: `iter.empty` X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=02efb796e3b875c8a4aa1adf8a3015cdd19796cd;p=onyx.git added: `iter.empty` --- 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 //