summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
> 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130