rust/hg-core/src/utils/hg_path.rs
changeset 47113 be579775c2d9
parent 47099 3da19db33cbc
child 47192 1249eb9cc332
--- a/rust/hg-core/src/utils/hg_path.rs	Fri Apr 16 12:12:04 2021 +0200
+++ b/rust/hg-core/src/utils/hg_path.rs	Fri Apr 16 12:12:41 2021 +0200
@@ -6,6 +6,7 @@
 // GNU General Public License version 2 or any later version.
 
 use std::borrow::Borrow;
+use std::borrow::Cow;
 use std::convert::TryFrom;
 use std::ffi::{OsStr, OsString};
 use std::fmt;
@@ -535,6 +536,24 @@
     }
 }
 
+impl From<HgPathBuf> for Cow<'_, HgPath> {
+    fn from(path: HgPathBuf) -> Self {
+        Cow::Owned(path)
+    }
+}
+
+impl<'a> From<&'a HgPath> for Cow<'a, HgPath> {
+    fn from(path: &'a HgPath) -> Self {
+        Cow::Borrowed(path)
+    }
+}
+
+impl<'a> From<&'a HgPathBuf> for Cow<'a, HgPath> {
+    fn from(path: &'a HgPathBuf) -> Self {
+        Cow::Borrowed(&**path)
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;