mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
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:
committed by
GitHub
parent
fefce25081
commit
25bccf4883
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user