Add a proc == for MemSlice.
This commit is contained in:
parent
0daca5c463
commit
1bb6775f92
1 changed files with 5 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue