Browse Source

helper function vec_to_array

pull/3/head
jake 4 years ago
parent
commit
ef8b80bfa8
  1. 7
      src/util.rs

7
src/util.rs

@ -43,6 +43,13 @@ macro_rules! utf8_to_utf16_array {
}
}
pub fn vec_to_array<T: Default + Copy, const N: usize>(vec: Vec<T>) -> [T; N] {
let mut result: [T; N] = [T::default(); N];
for (i, v) in vec.into_iter().enumerate() {
result[i] = v
}
result
}
#[cfg(test)]
mod test {

Loading…
Cancel
Save