hare

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

empty.ha (448B)


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