From 1fa9a68ee648219f05c448c2135016f4814a00ab Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Mon, 20 Jan 2025 00:10:31 +0100 Subject: [PATCH] refactor: use 'byte' instead of 'uint8' in ringbuffer example Signed-off-by: Christopher Arndt --- examples/jacket_ringbuffer.nim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/jacket_ringbuffer.nim b/examples/jacket_ringbuffer.nim index 9018ea1..4b46ce3 100644 --- a/examples/jacket_ringbuffer.nim +++ b/examples/jacket_ringbuffer.nim @@ -9,35 +9,35 @@ proc main() = let size = 32 var read, written: int - var data = [0x64.uint8, 0x65, 0x61, 0x64, 0x62, 0x65, 0x65, 0x66] - var recvBuf: array[8, uint8] + var data = [0x64.byte, 0x65, 0x61, 0x64, 0x62, 0x65, 0x65, 0x66] + var recvBuf: array[8, byte] let rb = ringbufferCreate(size.csize_t) debug fmt"Created ringbuffer of {size} bytes size." doAssert ringbufferReadSpace(rb) == 0 - written = cast[int](ringbufferWrite(rb, cast[cstring](data.addr), 4)) + written = ringbufferWrite(rb, cast[cstring](data.addr), 4).int doAssert written == 4 debug fmt"Written {written} bytes to ringbuffer." doAssert ringbufferReadSpace(rb) == 4 - written = cast[int](ringbufferWrite(rb, cast[cstring](data[4].addr), 4)) + written = ringbufferWrite(rb, cast[cstring](data[4].addr), 4).int doAssert written == 4 debug fmt"Written {written} bytes to ringbuffer." doAssert ringbufferReadSpace(rb) == 8 - read = cast[int](ringbufferRead(rb, cast[cstring](recvBuf.addr), 4)) + read = ringbufferRead(rb, cast[cstring](recvBuf.addr), 4).int doAssert read == 4 - debug fmt"Read {read} bytes from ringbuffer into receive buffer: {recvBuf}" + debug fmt"Read {read} bytes from ringbuffer. Receive buffer: {recvBuf}" doAssert ringbufferReadSpace(rb) == 4 - read = cast[int](ringbufferRead(rb, cast[cstring](recvBuf[4].addr), 4)) + read = ringbufferRead(rb, cast[cstring](recvBuf[4].addr), 4).int doAssert read == 4 - debug fmt"Read {read} bytes from ringbuffer into receive buffer: {recvBuf}" + debug fmt"Read {read} bytes from ringbuffer. Receive buffer: {recvBuf}" doAssert ringbufferReadSpace(rb) == 0