[]byte.clone()

pull/1315/head
Alexander Medvednikov 2019-07-25 18:07:16 +02:00
parent d8b83bdd00
commit 20a885ff1d
2 changed files with 16 additions and 0 deletions

View 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
}

View File

@ -177,3 +177,11 @@ pub fn (c byte) str() string {
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
}