distinctBase overload for values (#13746)

This commit is contained in:
Timothee Cour
2020-03-25 13:47:03 -07:00
committed by GitHub
parent 764a81ca25
commit 98753da331
2 changed files with 8 additions and 1 deletions

View File

@@ -122,7 +122,7 @@ echo f
- Added `net.getPeerCertificates` and `asyncnet.getPeerCertificates` for
retrieving the verified certificate chain of the peer we are connected to
through an SSL-wrapped `Socket`/`AsyncSocket`.
- Added `distinctBase` overload for values: `assert 12.MyInt.distinctBase == 12`
## Library changes

View File

@@ -71,6 +71,13 @@ proc distinctBase*(T: typedesc): typedesc {.magic: "TypeTrait".}
## Returns base type for distinct types, works only for distinct types.
## compile time error otherwise
since (1, 1):
template distinctBase*[T](a: T): untyped =
## overload for values
runnableExamples:
type MyInt = distinct int
doAssert 12.MyInt.distinctBase == 12
distinctBase(type(a))(a)
proc tupleLen*(T: typedesc[tuple]): int {.magic: "TypeTrait", since: (1, 1).}
## Return number of elements of `T`