Patchwork D9048: hg-core: impl TryFrom<PathBuff> for HgPathBuf

login
register
mail settings
Submitter phabricator
Date Sept. 18, 2020, 4:01 p.m.
Message ID <differential-rev-PHID-DREV-xzdunblfojwhvtx7o26k-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47223/
State Superseded
Headers show

Comments

phabricator - Sept. 18, 2020, 4:01 p.m.
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9048

AFFECTED FILES
  rust/hg-core/src/utils/hg_path.rs

CHANGE DETAILS




To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/utils/hg_path.rs b/rust/hg-core/src/utils/hg_path.rs
--- a/rust/hg-core/src/utils/hg_path.rs
+++ b/rust/hg-core/src/utils/hg_path.rs
@@ -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::*;