mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: document more builtin functions/methods (#14229)
This commit is contained in:
committed by
GitHub
parent
dcdfdf4dd8
commit
a2338dbb7c
@@ -64,6 +64,7 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
|
||||
vhalt()
|
||||
}
|
||||
|
||||
// panic_optional_not_set prints given optional not set and exits the process
|
||||
[noreturn]
|
||||
pub fn panic_optional_not_set(s string) {
|
||||
panic('optional not set ($s)')
|
||||
|
||||
@@ -17,14 +17,17 @@ pub fn ptr_str(ptr voidptr) string {
|
||||
return buf1
|
||||
}
|
||||
|
||||
// str returns string equivalent of x
|
||||
pub fn (x isize) str() string {
|
||||
return i64(x).str()
|
||||
}
|
||||
|
||||
// str returns string equivalent of x
|
||||
pub fn (x usize) str() string {
|
||||
return u64(x).str()
|
||||
}
|
||||
|
||||
// str returns string equivalent of cptr
|
||||
pub fn (cptr &char) str() string {
|
||||
return u64(cptr).hex()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ pub interface IError {
|
||||
code() int
|
||||
}
|
||||
|
||||
// str returns the message of IError
|
||||
pub fn (err IError) str() string {
|
||||
return match err {
|
||||
None__ {
|
||||
@@ -50,10 +51,12 @@ pub fn (err IError) str() string {
|
||||
// Error is the empty default implementation of `IError`.
|
||||
pub struct Error {}
|
||||
|
||||
// msg returns the message of Error
|
||||
pub fn (err Error) msg() string {
|
||||
return ''
|
||||
}
|
||||
|
||||
// code returns the code of Error
|
||||
pub fn (err Error) code() int {
|
||||
return 0
|
||||
}
|
||||
@@ -65,10 +68,12 @@ pub:
|
||||
code int
|
||||
}
|
||||
|
||||
// msg returns the message of the MessageError
|
||||
pub fn (err MessageError) msg() string {
|
||||
return err.msg
|
||||
}
|
||||
|
||||
// code returns the code of MessageError
|
||||
pub fn (err MessageError) code() int {
|
||||
return err.code
|
||||
}
|
||||
@@ -88,6 +93,7 @@ pub struct Option {
|
||||
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 }'
|
||||
|
||||
@@ -13,6 +13,7 @@ pub interface IError {
|
||||
code() int
|
||||
}
|
||||
|
||||
// str returns the message of IError
|
||||
pub fn (err IError) str() string {
|
||||
return match err {
|
||||
None__ {
|
||||
@@ -52,10 +53,12 @@ pub:
|
||||
code int
|
||||
}
|
||||
|
||||
// msg returns the message of MessageError
|
||||
pub fn (err MessageError) msg() string {
|
||||
return err.msg
|
||||
}
|
||||
|
||||
// code returns the code of MessageError
|
||||
pub fn (err MessageError) code() int {
|
||||
return err.code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user