diff rust/hg-core/src/utils.rs @ 42799:5399532510ae

rust: simply use TryInto to convert slice to array Since our rust module depends on TryInto, there's no point to avoid using it. While rewriting copy_into_array(), I noticed CPython interface doesn't check the length of the p1/p2 values, which is marked as TODO.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 17 Aug 2019 11:37:42 +0900
parents 4b3b27d567d5
children ce6797ef6eab
line wrap: on
line diff
--- a/rust/hg-core/src/utils.rs	Sat Aug 17 13:55:05 2019 +0900
+++ b/rust/hg-core/src/utils.rs	Sat Aug 17 11:37:42 2019 +0900
@@ -9,23 +9,6 @@
 
 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