1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

io: migrate the Reader API to Result instead of Option (#15229)

This commit is contained in:
Vincenzo Palazzo
2022-08-08 00:33:25 +01:00
committed by GitHub
parent 8c33a40c5a
commit b01f71d9da
13 changed files with 89 additions and 37 deletions

View File

@ -8,9 +8,9 @@ mut:
place int
}
fn (mut s StringReader) read(mut buf []u8) ?int {
fn (mut s StringReader) read(mut buf []u8) !int {
if s.place >= s.text.len {
return none
return IError(io.Eof{})
}
max_bytes := 100
end := if s.place + max_bytes >= s.text.len { s.text.len } else { s.place + max_bytes }