summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/typetraits.nim9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim
index e9579e824..f0838415b 100644
--- a/lib/pure/typetraits.nim
+++ b/lib/pure/typetraits.nim
@@ -35,8 +35,13 @@ proc `$`*(t: typedesc): string =
   ## An alias for `name`.
   name(t)
 
-proc arity*(t: typedesc): int {.magic: "TypeTrait".}
-  ## Returns the arity of the given type
+proc arity*(t: typedesc): int {.magic: "TypeTrait".} =
+  ## Returns the arity of the given type. This is the number of "type" components or
+  ## the number of generic parameters a given type ``t`` has.
+  runnableExamples:
+    assert arity(seq[string]) == 1
+    assert arity(array[3, int]) == 2
+    assert arity((int, int, float, string)) == 4
 
 proc genericHead*(t: typedesc): typedesc {.magic: "TypeTrait".}
   ## Accepts an instantiated generic type and returns its