New faults and syntax (#2034)

- Remove `[?]` syntax.
- Change `int!` to `int?` syntax.
- New `fault` declarations.
- Enum associated values can reference the calling enum.
This commit is contained in:
Christoffer Lerno
2025-03-10 00:11:35 +01:00
committed by GitHub
parent fefce25081
commit 25bccf4883
392 changed files with 3129 additions and 3658 deletions

View File

@@ -16,29 +16,29 @@ fn LimitReader* LimitReader.init(&self, InStream wrapped_stream, usz limit)
return self;
}
fn void! LimitReader.close(&self) @dynamic
fn void? LimitReader.close(&self) @dynamic
{
if (&self.wrapped_stream.close) return self.wrapped_stream.close();
}
fn usz! LimitReader.read(&self, char[] bytes) @dynamic
fn usz? LimitReader.read(&self, char[] bytes) @dynamic
{
if (self.limit == 0) return IoError.EOF?;
if (self.limit == 0) return io::EOF?;
usz m = min(bytes.len, self.limit);
usz n = self.wrapped_stream.read(bytes[:m])!;
self.limit -= n;
return n;
}
fn char! LimitReader.read_byte(&self) @dynamic
fn char? LimitReader.read_byte(&self) @dynamic
{
if (self.limit == 0) return IoError.EOF?;
if (self.limit == 0) return io::EOF?;
defer try self.limit--;
return self.wrapped_stream.read_byte();
}
fn usz! LimitReader.available(&self) @inline @dynamic
fn usz? LimitReader.available(&self) @inline @dynamic
{
return self.limit;
}