From c056a0d108d70932f33c75fd7f9dd5cb82808e1f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 22 Sep 2022 00:52:37 +0100 Subject: [PATCH] Add `slice.enumerated_array` --- core/slice/slice.odin | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/slice/slice.odin b/core/slice/slice.odin index e76a5599d..abc84787f 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -509,3 +509,10 @@ dot_product :: proc(a, b: $S/[]$T) -> (r: T, ok: bool) } return r, true } + + +// Convert a pointer to an enumerated array to a slice of the element type +enumerated_array :: proc(ptr: ^$T) -> []intrinsics.type_elem_type(T) + where intrinsics.type_is_enumerated_array(T) { + return ([^]intrinsics.type_elem_type(T))(ptr)[:len(T)] +} \ No newline at end of file