hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 10cee012664401590dcea742a901ffd585b0a3cf
parent 507cb19ddd2a545180689f78fb2cd781aaba8e65
Author: Bor Grošelj Simić <bgs@turminal.net>
Date:   Tue, 19 Apr 2022 02:29:31 +0200

bufio: remove an obsolete constraint of the api

fixed stream can now be both readable and writable

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>

Diffstat:
Mbufio/memstream.ha | 11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/bufio/memstream.ha b/bufio/memstream.ha @@ -14,11 +14,10 @@ export type memstream = struct { pos: size, }; -// Creates a stream for a fixed, caller-supplied buffer. Supports either read or -// write, but not both. All fixed streams are seekable; seeking a write stream -// will cause subsequent writes to overwrite existing contents of the buffer. -// The program aborts if writes would exceed the buffer's capacity. The stream -// doesn't have to be closed. +// Creates a stream for a fixed, caller-supplied buffer. All fixed streams are +// seekable; seeking a write stream will cause subsequent writes to overwrite +// existing contents of the buffer. The program aborts if writes would exceed +// the buffer's capacity. The stream doesn't have to be closed. export fn fixed(in: []u8, mode: io::mode) memstream = { let s = memstream { stream = io::stream { @@ -29,11 +28,9 @@ export fn fixed(in: []u8, mode: io::mode) memstream = { pos = 0, }; if (mode & io::mode::READ == io::mode::READ) { - assert(mode & io::mode::WRITE != io::mode::WRITE); s.stream.reader = &read; }; if (mode & io::mode::WRITE == io::mode::WRITE) { - assert(mode & io::mode::READ != io::mode::READ); s.stream.writer = &fixed_write; }; return s;