From 00f56b20d7e2edb903c7c486574ad793a078667a Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Tue, 5 Aug 2014 11:25:54 +0200 Subject: Adds usage example to typetraits.name(). Credit goes to fowl (http://forum.nimrod-lang.org/t/430). --- lib/pure/typetraits.nim | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit 1.4.1-2-gfad0