1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vlib/arrays: fix copy to not use memcpy for array, map, string (#13703)

This commit is contained in:
Nick Treleaven
2022-03-09 22:30:51 +00:00
committed by GitHub
parent de2fc87995
commit 4bea35b028
2 changed files with 31 additions and 1 deletions

View File

@@ -281,3 +281,15 @@ fn test_copy() {
assert copy(mut b, [8, 9]) == 2
assert b == [8, 9, 3, 7]
}
fn test_can_copy_bits() {
assert can_copy_bits<byte>()
assert can_copy_bits<int>()
assert can_copy_bits<voidptr>()
assert can_copy_bits<&byte>()
// autofree needs to intercept assign
assert !can_copy_bits<string>()
assert !can_copy_bits<[]int>()
// map not copyable
assert !can_copy_bits<map[string]int>()
}