--- a/rust/hg-core/src/utils.rs Wed Jul 10 10:16:28 2019 +0200
+++ b/rust/hg-core/src/utils.rs Tue Jul 09 11:49:49 2019 +0200
@@ -1,5 +1,22 @@
pub mod files;
+use std::convert::AsMut;
+
+/// Takes a slice and copies it into an array.
+///
+/// # Panics
+///
+/// Will panic if the slice and target array don't have the same length.
+pub fn copy_into_array<A, T>(slice: &[T]) -> A
+where
+ A: Sized + Default + AsMut<[T]>,
+ T: Copy,
+{
+ let mut a = Default::default();
+ <A as AsMut<[T]>>::as_mut(&mut a).copy_from_slice(slice);
+ a
+}
+
/// Replaces the `from` slice with the `to` slice inside the `buf` slice.
///
/// # Examples