changeset 45544:2d5dfc8fed55

hg-core: impl TryFrom<PathBuff> for HgPathBuf Differential Revision: https://phab.mercurial-scm.org/D9048
author Antoine Cezar <antoine.cezar@octobus.net>
date Tue, 15 Sep 2020 10:52:28 +0200
parents 2f8227a12592
children aebc976fd7d5
files rust/hg-core/src/utils/hg_path.rs
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/utils/hg_path.rs	Wed Sep 09 14:53:15 2020 +0200
+++ b/rust/hg-core/src/utils/hg_path.rs	Tue Sep 15 10:52:28 2020 +0200
@@ -6,6 +6,7 @@
 // GNU General Public License version 2 or any later version.
 
 use std::borrow::Borrow;
+use std::convert::TryFrom;
 use std::ffi::{OsStr, OsString};
 use std::fmt;
 use std::ops::Deref;
@@ -515,6 +516,13 @@
     Ok(buf)
 }
 
+impl TryFrom<PathBuf> for HgPathBuf {
+    type Error = HgPathError;
+    fn try_from(path: PathBuf) -> Result<Self, Self::Error> {
+        path_to_hg_path_buf(path)
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;