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

builtin,cgen: rename Option to _option (#14317)

This commit is contained in:
Daniel Däschle
2022-05-06 18:25:54 +02:00
committed by GitHub
parent 45fe87c9e3
commit 76cdf75299
12 changed files with 83 additions and 47 deletions

View File

@@ -104,6 +104,22 @@ pub fn (o Option) str() string {
return 'Option{ error: "$o.err" }'
}
pub struct _option {
state u8
err IError = none__
}
// str returns the Option type: ok, none, or error
pub fn (o _option) str() string {
if o.state == 0 {
return 'Option{ ok }'
}
if o.state == 1 {
return 'Option{ none }'
}
return 'Option{ error: "$o.err" }'
}
// trace_error prints to stderr a string and a backtrace of the error
fn trace_error(x string) {
eprintln('> ${@FN} | $x')