--- 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::*;