diff options
author | Araq <rumpf_a@web.de> | 2018-09-15 13:46:00 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-09-15 13:46:00 +0200 |
commit | 0841eaa273be54740fe84afbcb371f85e8854a5e (patch) | |
tree | b51ea5fd72031b9fd4bce1d4d65a3b94e900bcc3 /lib/pure | |
parent | 4c347871071541d4e01f8d2c3a0593e84454219c (diff) | |
download | Nim-0841eaa273be54740fe84afbcb371f85e8854a5e.tar.gz |
typetraits.arity: improve the documentation; fixes #8965
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/typetraits.nim | 9 |
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 |