diff rust/hg-core/src/dirstate/parsers.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 cc424cc16704
children 7a01778bc7b7
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/parsers.rs	Sat Aug 17 13:55:05 2019 +0900
+++ b/rust/hg-core/src/dirstate/parsers.rs	Sat Aug 17 11:37:42 2019 +0900
@@ -5,7 +5,6 @@
 
 use crate::{
     dirstate::{CopyMap, EntryState, StateMap},
-    utils::copy_into_array,
     DirstateEntry, DirstatePackError, DirstateParents, DirstateParseError,
 };
 use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
@@ -31,8 +30,8 @@
 
     let mut curr_pos = PARENT_SIZE * 2;
     let parents = DirstateParents {
-        p1: copy_into_array(&contents[..PARENT_SIZE]),
-        p2: copy_into_array(&contents[PARENT_SIZE..curr_pos]),
+        p1: contents[..PARENT_SIZE].try_into().unwrap(),
+        p2: contents[PARENT_SIZE..curr_pos].try_into().unwrap(),
     };
 
     while curr_pos < contents.len() {