mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: C++ compiler support
This commit is contained in:
@ -4,21 +4,21 @@
|
||||
module builtin
|
||||
/*
|
||||
struct Option2<T> {
|
||||
data T
|
||||
error string
|
||||
ecode int
|
||||
ok bool
|
||||
is_none bool
|
||||
error string
|
||||
ecode int
|
||||
data T
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
struct Option {
|
||||
data [400]byte
|
||||
error string
|
||||
ecode int
|
||||
ok bool
|
||||
is_none bool
|
||||
error string
|
||||
ecode int
|
||||
data [400]byte
|
||||
}
|
||||
|
||||
pub fn (o Option) str() string {
|
||||
@ -46,19 +46,24 @@ fn opt_ok(data voidptr, size int) Option {
|
||||
// used internally when returning `none`
|
||||
fn opt_none() Option {
|
||||
return Option{
|
||||
ok: false
|
||||
is_none: true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error(s string) Option {
|
||||
return Option{
|
||||
ok: false
|
||||
is_none: false
|
||||
error: s
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error_with_code(s string, code int) Option {
|
||||
return Option{
|
||||
ok: false
|
||||
is_none: false
|
||||
error: s
|
||||
ecode: code
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user