This commit is contained in:
Zahary Karadjov 2017-06-19 23:01:41 +03:00 • committed by Andreas Rumpf
commit 07d50cedf0
3 changed files with 32 additions and 1 deletions

22
tests/concepts/t5983.nim Normal file
View file

@ -0,0 +1,22 @@
discard """
output: "20.0 USD"
"""
import typetraits
const currencies = ["USD", "EUR"] # in real code 120 currencies
type USD* = distinct float # in real code 120 types generates using macro
type EUR* = distinct float
type CurrencyAmount = concept c
type t = c.type
const name = c.type.name
name in currencies
proc `$`(x: CurrencyAmount): string =
$float(x) & " " & x.name
let amount = 20.USD
echo amount