summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorVarriount <Varriount@users.noreply.github.com>2014-08-06 22:54:35 -0400
committerVarriount <Varriount@users.noreply.github.com>2014-08-06 22:54:35 -0400
commit0db99beecb6c28e2a5d9ee54670125d88d0b9378 (patch)
tree7201c5df445dfad3d62946c87c2be9edbba791c9 /lib
parent505b4158aa453bc370b5b4a3ec5898484f29c189 (diff)
parent5c9d6762e48f0f5e70fed848ba11e79c86427206 (diff)
downloadNim-0db99beecb6c28e2a5d9ee54670125d88d0b9378.tar.gz
Merge pull request #1446 from gradha/pr_links_typetraits_module
Links typetraits module
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/typetraits.nim23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim
index e7bd363cf..3203ee699 100644
--- a/lib/pure/typetraits.nim
+++ b/lib/pure/typetraits.nim
@@ -11,7 +11,26 @@
 ## working with types
 
 proc name*(t: typedesc): string {.magic: "TypeTrait".}
-  ## Returns the name of the given type
+  ## Returns the name of the given type.
+  ##
+  ## Example:
+  ##
+  ## .. code-block::
+  ##
+  ##   import typetraits
+  ##
+  ##   proc `$`*[T](some:typedesc[T]): string = name(T)
+  ##
+  ##   template test(x): stmt =
+  ##     echo "type: ", type(x), ", value: ", x
+  ##
+  ##   test 42
+  ##   # --> type: int, value: 42
+  ##   test "Foo"
+  ##   # --> type: string, value: Foo
+  ##   test(@['A','B'])
+  ##   # --> type: seq[char], value: @[A, B]
+
 
 proc arity*(t: typedesc): int {.magic: "TypeTrait".}
-  ## Returns the arity of the given type
\ No newline at end of file
+  ## Returns the arity of the given type