D7523: rust-hg-path: implement `Display` for `HgPath` and `HgPathBuf`
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Tue Dec 10 10:46:44 EST 2019
Closed by commit rHGc27e688fcdc3: rust-hg-path: implement `Display` for `HgPath` and `HgPathBuf` (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7523?vs=18421&id=18578
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, pulkit
Cc: durin42, kevincox, mercurial-devel
More information about the Mercurial-devel
mailing list