Merge pull request #5141 from c-blake/devel

Add a proc `==` for MemSlice.
This commit is contained in:
Andreas Rumpf
2017-01-06 13:15:10 +01:00
committed by GitHub

View File

@@ -271,6 +271,11 @@ type MemSlice* = object ## represent slice of a MemFile for iteration over deli
data*: pointer
size*: int
proc `==`*(x, y: MemSlice): bool =
## Compare a pair of MemSlice for strict equality.
proc memcmp(a, b: pointer, n:int):int {.importc: "memcmp",header: "string.h".}
result = (x.size == y.size and memcmp(x.data, y.data, x.size) == 0)
proc `$`*(ms: MemSlice): string {.inline.} =
## Return a Nim string built from a MemSlice.
var buf = newString(ms.size)