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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
}