builtin: voidptr.str() and byteptr.str()

pull/4700/head
ka-weihe 2020-05-04 13:20:18 +02:00 committed by GitHub
parent d75f286230
commit a72f3ed0c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -345,6 +345,14 @@ pub fn (nn i64) hex() string {
return u64(nn).hex()
}
pub fn (nn voidptr) str() string {
return u64(nn).hex()
}
pub fn (nn byteptr) str() string {
return u64(nn).hex()
}
// ----- utilities functions -----
pub fn (a []byte) contains(val byte) bool {

View File

@ -71,6 +71,10 @@ fn test_str_methods() {
assert u32(-1).str() == '4294967295'
assert u64(1).str() == '1'
assert u64(-1).str() == '18446744073709551615'
assert voidptr(-1).str() == 'ffffffffffffffff'
assert voidptr(1).str() == '1'
assert byteptr(-1).str() == 'ffffffffffffffff'
assert byteptr(1).str() == '1'
}
fn test_and_precendence() {