summary refs log tree commit diff stats
path: root/lib/core/unsigned.nim
diff options
context:
space:
mode:
authordef <dennis@felsin9.de>2014-06-27 15:14:45 +0200
committerdef <dennis@felsin9.de>2014-06-27 15:19:09 +0200
commit79cdb26b4659005c8d9ae2d03c868b78fc2622f5 (patch)
tree0718d12da708f97989f4936a389b4ee8d6bd5ad7 /lib/core/unsigned.nim
parent92d1da407a401490a664843322789f502b975131 (diff)
downloadNim-79cdb26b4659005c8d9ae2d03c868b78fc2622f5.tar.gz
Add missing operators for uint and uint64: `+=`, `-=`, `*=`
Diffstat (limited to 'lib/core/unsigned.nim')
-rw-r--r--lib/core/unsigned.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/core/unsigned.nim b/lib/core/unsigned.nim
index a3ddd4125..db46c0c0b 100644
--- a/lib/core/unsigned.nim
+++ b/lib/core/unsigned.nim
@@ -57,3 +57,16 @@ proc `<=`*[T: SomeUInt](x, y: T): bool {.magic: "LeU", noSideEffect.}
 
 proc `<`*[T: SomeUInt](x, y: T): bool {.magic: "LtU", noSideEffect.}
   ## Returns true iff ``unsigned(x) < unsigned(y)``.
+
+proc `+=`*[T: uint|uint64](x: var T, y: T) {.magic: "Inc", noSideEffect.}
+  ## Increments uints and uint64s, uint8..uint32 are TOrdinals, and already
+  ## have a definition in the System module.
+
+proc `-=`*[T: uint|uint64](x: var T, y: T) {.magic: "Dec", noSideEffect.}
+  ## Decrements uints and uint64s, uint8..uint32 are TOrdinals, and already
+  ## have a definition in the System module.
+
+proc `*=`*[T: uint|uint64](x: var T, y: T) {.inline, noSideEffect.} =
+  ## Binary `*=` operator for uints and uint64s, uint8..uint32 are TOrdinals,
+  ## and already have a definition in the System module.
+  x = x * y