diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-09-19 08:09:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-19 08:09:30 +0200 |
commit | a892d519a60e08212ea05e99bb9f858e6673ee6b (patch) | |
tree | de44439e87443335c5d8877301f367256a29b4e8 | |
parent | 34f0b91104e6853b81c56a5fa68c29b49394b76e (diff) | |
parent | 27734852da2f4982249ccb3ce48e7ba8d4d2f1c9 (diff) | |
download | Nim-a892d519a60e08212ea05e99bb9f858e6673ee6b.tar.gz |
Merge pull request #9002 from nim-lang/openarray-equals
Implements the equals operator for openarray
-rw-r--r-- | lib/system.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 353500a4a..49e6a396d 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2332,6 +2332,16 @@ proc `==`*[I, T](x, y: array[I, T]): bool = return result = true +proc `==`*[T](x, y: openarray[T]): bool = + if x.len != y.len: + return false + + for f in low(x)..high(x): + if x[f] != y[f]: + return false + + result = true + proc `@`*[T](a: openArray[T]): seq[T] = ## turns an openarray into a sequence. This is not as efficient as turning ## a fixed length array into a sequence as it always copies every element |