Add `len` for tuples

This commit is contained in:
Zahary Karadjov 2019-10-02 16:24:59 +03:00
parent 62c1bebe2e
commit 2bdd2fab6e
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 7 additions and 0 deletions

View File

@ -24,3 +24,10 @@ proc toArray*[T](N: static int, data: openarray[T]): array[N, T] =
template anonConst*(val: untyped): untyped =
const c = val
c
when not compiles(len((1, 2))):
import typetraits
func len*(x: tuple): int =
arity(type(x))