hare

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

zero.ha (421B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use bytes;
      5 
      6 const _zero_vt: vtable = vtable {
      7 	reader = &zero_read,
      8 	writer = &empty_write,
      9 	...
     10 };
     11 
     12 const _zero: stream = &_zero_vt;
     13 
     14 // A [[stream]] which always reads zeroes and discards any writes.
     15 export const zero: *stream = &_zero;
     16 
     17 fn zero_read(s: *stream, buf: []u8) (size | EOF | error) = {
     18 	bytes::zero(buf);
     19 	return len(buf);
     20 };