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

all: change optional to result of io (#16075)

This commit is contained in:
yuyi
2022-10-16 14:28:57 +08:00
committed by GitHub
parent 6e46933c55
commit f6844e9766
187 changed files with 1885 additions and 1874 deletions

View File

@ -107,9 +107,9 @@ pub fn (r BufferedReader) end_of_stream() bool {
// read_line attempts to read a line from the buffered reader
// it will read until it finds a new line character (\n) or
// the end of stream
pub fn (mut r BufferedReader) read_line() ?string {
pub fn (mut r BufferedReader) read_line() !string {
if r.end_of_stream {
return none
return error('none')
}
mut line := []u8{}
for {
@ -119,7 +119,7 @@ pub fn (mut r BufferedReader) read_line() ?string {
// We are at the end of the stream
if line.len == 0 {
// we had nothing so return nothing
return none
return error('none')
}
return line.bytestr()
}
@ -144,5 +144,5 @@ pub fn (mut r BufferedReader) read_line() ?string {
line << r.buf[r.offset..i]
r.offset = i
}
return none
return error('none')
}