diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 78591e8852..ea4278fe0c 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -251,3 +251,13 @@ pub fn (b []byte) hex() string { } return string(hex) } + +// TODO: implement for all types +pub fn copy(dst, src []byte) int { + if dst.len > 0 && src.len > 0 { + min := if dst.len < src.len { dst.len } else { src.len } + C.memcpy(dst.data, src.left(min).data, dst.element_size*min) + return min + } + return 0 +}