Implement From<Vec<u32>> for dc_array_t and use it instead of new()

This commit is contained in:
Alexander Krotov
2019-08-11 20:47:17 +03:00
parent 16f891c290
commit 6c95d008e0
4 changed files with 32 additions and 27 deletions

View File

@@ -147,6 +147,12 @@ impl dc_array_t {
}
}
impl From<Vec<u32>> for dc_array_t {
fn from(array: Vec<u32>) -> Self {
dc_array_t::Uint(array.iter().map(|&x| x as uintptr_t).collect())
}
}
impl From<Vec<dc_location>> for dc_array_t {
fn from(array: Vec<dc_location>) -> Self {
dc_array_t::Locations(array)