mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
builtin: move byte methods from rune.v to int.v (#11987)
This commit is contained in:
parent
6967a47e07
commit
07d65b2aab
2 changed files with 24 additions and 24 deletions
|
@ -39,27 +39,3 @@ pub fn (ra []rune) string() string {
|
|||
unsafe { sb.free() }
|
||||
return res
|
||||
}
|
||||
|
||||
// Define this on byte as well, so that we can do `s[0].is_capital()`
|
||||
pub fn (c byte) is_capital() bool {
|
||||
return c >= `A` && c <= `Z`
|
||||
}
|
||||
|
||||
pub fn (b []byte) clone() []byte {
|
||||
mut res := []byte{len: b.len}
|
||||
// mut res := make([]byte, {repeat:b.len})
|
||||
for i in 0 .. b.len {
|
||||
res[i] = b[i]
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// TODO: remove this once runes are implemented
|
||||
pub fn (b []byte) bytestr() string {
|
||||
unsafe {
|
||||
buf := malloc_noscan(b.len + 1)
|
||||
vmemcpy(buf, b.data, b.len)
|
||||
buf[b.len] = 0
|
||||
return tos(buf, b.len)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue