1
0
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:
Uwe Krüger
2020-05-18 15:51:36 +02:00
committed by GitHub
parent 857276e81f
commit 9a237c3e82
32 changed files with 268 additions and 150 deletions

View File

@ -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
}
}
}