questionable/questionable/operators.nim
2021-03-11 16:17:26 +01:00

13 lines
368 B
Nim

template liftUnary*(T: type, operator: untyped) =
template `operator`*(a: T): untyped =
a ->? `operator`(a.unsafeGet())
template liftBinary*(T: type, operator: untyped) =
template `operator`*(a: T, b: T): untyped =
(a, b) ->? `operator`(a.unsafeGet, b.unsafeGet)
template `operator`*(a: T, b: typed): untyped =
a ->? `operator`(a.unsafeGet(), b)