Skip to content

Commit

Permalink
proc-$ to stringify typedesc
Browse files Browse the repository at this point in the history
  • Loading branch information
cdunn2001 committed May 18, 2017
1 parent abb1fa4 commit 87862cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pure/typetraits.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ proc name*(t: typedesc): string {.magic: "TypeTrait".}
##
## import typetraits
##
## proc `$`*(T: typedesc): string = name(T)
##
## template test(x): stmt =
## echo "type: ", type(x), ", value: ", x
##
Expand All @@ -31,6 +29,10 @@ proc name*(t: typedesc): string {.magic: "TypeTrait".}
## test(@['A','B'])
## # --> type: seq[char], value: @[A, B]

proc `$`*(t: typedesc): string =
## Stringify a type, so that "echo type(42)" will work
name(t)

proc arity*(t: typedesc): int {.magic: "TypeTrait".}
## Returns the arity of the given type

Expand Down

0 comments on commit 87862cc

Please sign in to comment.