mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
03864e4ab8
commit
3b5de71e60
@ -87,3 +87,7 @@ pub fn (e &Error) free() {
|
||||
pub fn (n &None__) free() {
|
||||
unsafe { n.msg.free() }
|
||||
}
|
||||
|
||||
pub fn (_ none) str() string {
|
||||
return 'none'
|
||||
}
|
||||
|
14
vlib/v/tests/string_optional_none_test.v
Normal file
14
vlib/v/tests/string_optional_none_test.v
Normal file
@ -0,0 +1,14 @@
|
||||
struct MyError {
|
||||
code int
|
||||
msg string
|
||||
}
|
||||
|
||||
fn foo() int | none | IError {
|
||||
return IError(MyError{})
|
||||
}
|
||||
|
||||
fn test_string_optional_none() {
|
||||
x := foo()
|
||||
println(x)
|
||||
assert true
|
||||
}
|
Loading…
Reference in New Issue
Block a user