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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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>()
}