Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-cpython/src/parsers.rs @ 42815: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 | 98901eb12245 |
children | 2e1f74cc3350 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/parsers.rs Sat Aug 17 13:55:05 2019 +0900 +++ b/rust/hg-cpython/src/parsers.rs Sat Aug 17 11:37:42 2019 +0900 @@ -15,10 +15,11 @@ PythonObject, ToPyObject, }; use hg::{ - pack_dirstate, parse_dirstate, utils::copy_into_array, DirstateEntry, + pack_dirstate, parse_dirstate, DirstateEntry, DirstatePackError, DirstateParents, DirstateParseError, PARENT_SIZE, }; use std::collections::HashMap; +use std::convert::TryInto; use libc::c_char; @@ -120,8 +121,8 @@ &mut dirstate_map, &copies?, DirstateParents { - p1: copy_into_array(&p1), - p2: copy_into_array(&p2), + p1: p1.try_into().unwrap(), + p2: p2.try_into().unwrap(), }, Duration::from_secs(now.as_object().extract::<u64>(py)?), ) {