D7523: rust-hg-path: implement `Display` for `HgPath` and `HgPathBuf`
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Mon Dec 2 09:20:18 EST 2019
Alphare marked an inline comment as done.
Alphare updated this revision to Diff 18421.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7523?vs=18399&id=18421
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7523/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7523
AFFECTED FILES
rust/hg-core/src/utils/hg_path.rs
CHANGE DETAILS
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
@@ -7,6 +7,7 @@
use std::borrow::Borrow;
use std::ffi::{OsStr, OsString};
+use std::fmt;
use std::ops::Deref;
use std::path::{Path, PathBuf};
@@ -162,6 +163,12 @@
}
}
+impl fmt::Display for HgPath {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", String::from_utf8_lossy(&self.inner))
+ }
+}
+
#[derive(Eq, Ord, Clone, PartialEq, PartialOrd, Debug, Hash)]
pub struct HgPathBuf {
inner: Vec<u8>,
@@ -185,6 +192,12 @@
}
}
+impl fmt::Display for HgPathBuf {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", String::from_utf8_lossy(&self.inner))
+ }
+}
+
impl Deref for HgPathBuf {
type Target = HgPath;
To: Alphare, #hg-reviewers, kevincox
Cc: durin42, kevincox, mercurial-devel
More information about the Mercurial-devel
mailing list