From a31d0ea6509c6e089f993b4a0657c5f9ef832124 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 25 Nov 2021 22:08:11 -0600 Subject: [PATCH] iter.enumerate is more friendly --- core/container/iter.onyx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/container/iter.onyx b/core/container/iter.onyx index c035c8d1..4a52400f 100644 --- a/core/container/iter.onyx +++ b/core/container/iter.onyx @@ -249,7 +249,14 @@ const :: (value: $T) -> Iterator(T) { value: T; } -enumerate :: (it: Iterator($T), start_index: i32 = 0) -> Iterator(Enumeration_Value(T)) { +enumerate :: #match {} +#match enumerate macro (it: $T, start_index: i32 = 0) -> #auto where Iterable(T) { + as_iterator :: as_iterator + enumerate :: enumerate + return enumerate(as_iterator(it), start_index); +} + +#match enumerate (it: Iterator($T), start_index: i32 = 0) -> Iterator(Enumeration_Value(T)) { Enumeration_Context :: struct (T: type_expr) { iterator: Iterator(T); current_index: i32; -- 2.25.1