toString --> $.
This commit is contained in:
parent
c6d609f88b
commit
c373c7209a
2 changed files with 2 additions and 2 deletions
|
|
@ -254,7 +254,7 @@ type MemSlice* = object ## represent slice of a MemFile for iteration over deli
|
|||
|
||||
proc c_memcpy(a, b: pointer, n: int) {.importc: "memcpy", header: "<string.h>".}
|
||||
|
||||
proc toString*(ms: MemSlice): string {.inline.} =
|
||||
proc `$`*(ms: MemSlice): string {.inline.} =
|
||||
## Return a Nim string built from a MemSlice.
|
||||
var buf = newString(ms.size)
|
||||
c_memcpy(addr(buf[0]), ms.data, ms.size)
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ import memfiles
|
|||
var inp = memfiles.open("readme.txt")
|
||||
for mem in memSlices(inp):
|
||||
if mem.size > 3:
|
||||
echo("#" & toString(mem) & "#")
|
||||
echo("#" & $mem & "#")
|
||||
close(inp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue