I didn't know you could do this, but apparently this works as well (tried on 
both 0.18.0 and 0.19.0).
    
    
    type
      MyType = distinct int
    
    template Cast[T](value: typed): T =
      cast[T](value)
    
    let a = Cast[int](3.MyType)
    echo a
    # prints 3
    
    
    Run

Reply via email to