commit 66e538a14b032987c71188c37f4e04dc33a24028
parent b79e6bd483c6ce99964e2c8f393fe5b4c988525d
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 2 Feb 2021 13:50:13 -0500
all: simplify match statements
Following harec improvements
Diffstat:
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/io/stream.ha b/io/stream.ha
@@ -30,7 +30,7 @@ export type stream = struct {
// the number of bytes read.
export fn read(s: *stream, buf: []u8) (size | EOF | error) = {
return match (s.reader) {
- null => unsupported: error,
+ null => unsupported,
r: *reader => r(s, buf),
};
};
@@ -39,7 +39,7 @@ export fn read(s: *stream, buf: []u8) (size | EOF | error) = {
// the number of bytes written.
export fn write(s: *stream, buf: const []u8) (size | error) = {
return match (s.writer) {
- null => unsupported: error,
+ null => unsupported,
w: *writer => w(s, buf),
};
};
@@ -47,7 +47,7 @@ export fn write(s: *stream, buf: const []u8) (size | error) = {
// Closes the stream.
export fn close(s: *stream) (error | void) = {
return match (s.closer) {
- null => unsupported: error,
+ null => unsupported,
c: *closer => c(s),
};
};
diff --git a/io/types.ha b/io/types.ha
@@ -20,8 +20,8 @@ export type EOF = void;
export fn errstr(err: error) str = {
return match (err) {
err: os_error => err.string(err.data),
- closed => "This stream has been closed",
unsupported => "The requested operation is not supported",
+ closed => "This stream has been closed",
};
};
diff --git a/strings/dup.ha b/strings/dup.ha
@@ -7,7 +7,7 @@ export fn dup(s: const str) str = {
let in = &s: *types::string;
let buf: *[*]u8 = match (rt::malloc(in.length + 1z)) {
null => abort("Out of memory"),
- v: *void => v: *[*]u8,
+ v: *void => v,
};
bytes::copy(buf[..in.length + 1z], in.data[..in.length + 1z]);
let out = types::string {