mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
[]byte.clone()
This commit is contained in:
parent
d8b83bdd00
commit
20a885ff1d
8
vlib/builtin/byte_test.v
Normal file
8
vlib/builtin/byte_test.v
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fn test_clone() {
|
||||||
|
a := [byte(0), 1, 2]
|
||||||
|
b := a.clone()
|
||||||
|
assert b.len == 3
|
||||||
|
assert b[0] == 0
|
||||||
|
assert b[1] == 1
|
||||||
|
assert b[2] == 2
|
||||||
|
}
|
@ -177,3 +177,11 @@ pub fn (c byte) str() string {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (b []byte) clone() []byte {
|
||||||
|
mut res := [byte(0); b.len]
|
||||||
|
for i := 0; i < b.len; i++ {
|
||||||
|
res[i] = b[i]
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user