lib/std/io: add Stream.read_all (#843)

* lib/std/io: add Stream.read_all

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>

* lib/std/core: use shortened receiver notation

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>

---------

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
Pierre Curto
2023-07-10 20:13:31 +02:00
committed by GitHub
parent e2676a5c7f
commit 2437573a8f
8 changed files with 66 additions and 58 deletions

View File

@@ -6,18 +6,18 @@ struct StringIterator
usz current;
}
fn void StringIterator.reset(StringIterator* this)
fn void StringIterator.reset(&self)
{
this.current = 0;
self.current = 0;
}
fn Char32! StringIterator.next(StringIterator* this)
fn Char32! StringIterator.next(&self)
{
usz len = this.utf8.len;
usz current = this.current;
usz len = self.utf8.len;
usz current = self.current;
if (current >= len) return IteratorResult.NO_MORE_ELEMENT?;
usz read = (len - current < 4 ? len - current : 4);
Char32 res = conv::utf8_to_char32(&this.utf8[current], &read)!;
this.current += read;
Char32 res = conv::utf8_to_char32(&self.utf8[current], &read)!;
self.current += read;
return res;
}