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

all: change optional to result in most of the libraries (#16123)

This commit is contained in:
yuyi
2022-10-21 03:14:33 +08:00
committed by GitHub
parent 0d368562f4
commit 51f4d99399
75 changed files with 439 additions and 446 deletions

View File

@@ -23,7 +23,7 @@ struct Termios {
// an error if the line is empty.
// The `prompt` `string` is output as a prefix text for the input capturing.
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
pub fn (mut r Readline) read_line_utf8(prompt string) ?[]rune {
pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
r.current = []rune{}
r.cursor = 0
r.prompt = prompt
@@ -49,8 +49,8 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ?[]rune {
// read_line does the same as `read_line_utf8` but returns user input as a `string`.
// (As opposed to `[]rune` returned by `read_line_utf8`).
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt)?
pub fn (mut r Readline) read_line(prompt string) !string {
s := r.read_line_utf8(prompt)!
return s.string()
}
@@ -63,9 +63,9 @@ pub fn (mut r Readline) read_line(prompt string) ?string {
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
// NOTE that this version of `read_line_utf8` is a standalone function without
// persistent functionalities (e.g. history).
pub fn read_line_utf8(prompt string) ?[]rune {
pub fn read_line_utf8(prompt string) ![]rune {
mut r := Readline{}
s := r.read_line_utf8(prompt)?
s := r.read_line_utf8(prompt)!
return s
}
@@ -73,8 +73,8 @@ pub fn read_line_utf8(prompt string) ?[]rune {
// (As opposed to `[]rune` as returned by `read_line_utf8`).
// NOTE that this version of `read_line` is a standalone function without
// persistent functionalities (e.g. history).
pub fn read_line(prompt string) ?string {
pub fn read_line(prompt string) !string {
mut r := Readline{}
s := r.read_line(prompt)?
s := r.read_line(prompt)!
return s
}

View File

@@ -15,7 +15,7 @@ struct Termios {}
// The `prompt` `string` is output as a prefix text for the input capturing.
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
pub fn (mut r Readline) read_line(prompt string) ?string {
pub fn (mut r Readline) read_line(prompt string) !string {
res := ''
print(prompt)
#const rl = $readline.createInterface({input: $process.stdin,output: $process.stdout,prompt: prompt.str})
@@ -25,8 +25,8 @@ pub fn (mut r Readline) read_line(prompt string) ?string {
return res
}
pub fn read_line(prompt string) ?string {
pub fn read_line(prompt string) !string {
mut r := Readline{}
s := r.read_line(prompt)?
s := r.read_line(prompt)!
return s
}

View File

@@ -133,7 +133,7 @@ pub fn (r Readline) read_char() !int {
// an error if the line is empty.
// The `prompt` `string` is output as a prefix text for the input capturing.
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
pub fn (mut r Readline) read_line_utf8(prompt string) ?[]rune {
pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
r.current = []rune{}
r.cursor = 0
r.prompt = prompt
@@ -168,8 +168,8 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ?[]rune {
// read_line does the same as `read_line_utf8` but returns user input as a `string`.
// (As opposed to `[]rune` returned by `read_line_utf8`).
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt)?
pub fn (mut r Readline) read_line(prompt string) !string {
s := r.read_line_utf8(prompt)!
return s.string()
}
@@ -182,9 +182,9 @@ pub fn (mut r Readline) read_line(prompt string) ?string {
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
// NOTE that this version of `read_line_utf8` is a standalone function without
// persistent functionalities (e.g. history).
pub fn read_line_utf8(prompt string) ?[]rune {
pub fn read_line_utf8(prompt string) ![]rune {
mut r := Readline{}
s := r.read_line_utf8(prompt)?
s := r.read_line_utf8(prompt)!
return s
}
@@ -192,9 +192,9 @@ pub fn read_line_utf8(prompt string) ?[]rune {
// (As opposed to `[]rune` as returned by `read_line_utf8`).
// NOTE that this version of `read_line` is a standalone function without
// persistent functionalities (e.g. history).
pub fn read_line(prompt string) ?string {
pub fn read_line(prompt string) !string {
mut r := Readline{}
s := r.read_line(prompt)?
s := r.read_line(prompt)!
return s
}

View File

@@ -24,7 +24,7 @@ struct Termios {
// an error if the line is empty.
// The `prompt` `string` is output as a prefix text for the input capturing.
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
pub fn (mut r Readline) read_line_utf8(prompt string) ?[]rune {
pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
r.current = []rune{}
r.cursor = 0
r.prompt = prompt
@@ -47,8 +47,8 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ?[]rune {
// read_line does the same as `read_line_utf8` but returns user input as a `string`.
// (As opposed to `[]rune` returned by `read_line_utf8`).
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt)?
pub fn (mut r Readline) read_line(prompt string) !string {
s := r.read_line_utf8(prompt)!
return s.string()
}
@@ -61,9 +61,9 @@ pub fn (mut r Readline) read_line(prompt string) ?string {
// read_line_utf8 is the main method of the `readline` module and `Readline` struct.
// NOTE that this version of `read_line_utf8` is a standalone function without
// persistent functionalities (e.g. history).
pub fn read_line_utf8(prompt string) ?[]rune {
pub fn read_line_utf8(prompt string) ![]rune {
mut r := Readline{}
s := r.read_line_utf8(prompt)?
s := r.read_line_utf8(prompt)!
return s
}
@@ -71,8 +71,8 @@ pub fn read_line_utf8(prompt string) ?[]rune {
// (As opposed to `[]rune` as returned by `read_line_utf8`).
// NOTE that this version of `read_line` is a standalone function without
// persistent functionalities (e.g. history).
pub fn read_line(prompt string) ?string {
pub fn read_line(prompt string) !string {
mut r := Readline{}
s := r.read_line(prompt)?
s := r.read_line(prompt)!
return s
}