rust/hg-core/src/utils/files.rs
changeset 46596 d2e61f00ee9d
parent 46481 0d734c0ae1cf
child 46742 91ab5190a3de
--- a/rust/hg-core/src/utils/files.rs	Wed Feb 17 12:24:53 2021 +0100
+++ b/rust/hg-core/src/utils/files.rs	Wed Feb 17 11:21:34 2021 +0100
@@ -17,6 +17,7 @@
 use lazy_static::lazy_static;
 use same_file::is_same_file;
 use std::borrow::{Cow, ToOwned};
+use std::ffi::OsStr;
 use std::fs::Metadata;
 use std::iter::FusedIterator;
 use std::ops::Deref;
@@ -40,8 +41,13 @@
 // that's why Vec<u8> is returned.
 #[cfg(unix)]
 pub fn get_bytes_from_path(path: impl AsRef<Path>) -> Vec<u8> {
+    get_bytes_from_os_str(path.as_ref())
+}
+
+#[cfg(unix)]
+pub fn get_bytes_from_os_str(str: impl AsRef<OsStr>) -> Vec<u8> {
     use std::os::unix::ffi::OsStrExt;
-    path.as_ref().as_os_str().as_bytes().to_vec()
+    str.as_ref().as_bytes().to_vec()
 }
 
 /// An iterator over repository path yielding itself and its ancestors.