diff rust/hg-cpython/src/dirstate/non_normal_entries.rs @ 47124:cd8ca38fccff

rust: Use `&HgPath` instead of `&HgPathBuf` in may APIs Getting the former (through `Deref`) is almost the only useful thing one can do with the latter anyway. With this changes, API become more flexible for the "provider" of these paths which may store something else that Deref?s to HgPath, such as `std::borrow::Cow<HgPath>`. Using `Cow` can help reduce memory alloactions and copying. Differential Revision: https://phab.mercurial-scm.org/D10558
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 30 Apr 2021 19:57:46 +0200
parents e061a1df32a8
children ed1583a845d2
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/non_normal_entries.rs	Fri Apr 30 18:24:54 2021 +0200
+++ b/rust/hg-cpython/src/dirstate/non_normal_entries.rs	Fri Apr 30 19:57:46 2021 +0200
@@ -12,7 +12,7 @@
 };
 
 use crate::dirstate::DirstateMap;
-use hg::utils::hg_path::HgPathBuf;
+use hg::utils::hg_path::HgPath;
 use std::cell::RefCell;
 
 py_class!(pub class NonNormalEntries |py| {
@@ -54,16 +54,13 @@
         Ok(true)
     }
 
-    fn translate_key(
-        py: Python,
-        key: &HgPathBuf,
-    ) -> PyResult<Option<PyBytes>> {
+    fn translate_key(py: Python, key: &HgPath) -> PyResult<Option<PyBytes>> {
         Ok(Some(PyBytes::new(py, key.as_bytes())))
     }
 }
 
 type NonNormalEntriesIter<'a> =
-    Box<dyn Iterator<Item = &'a HgPathBuf> + Send + 'a>;
+    Box<dyn Iterator<Item = &'a HgPath> + Send + 'a>;
 
 py_shared_iterator!(
     NonNormalEntriesIterator,