##// END OF EJS Templates
rust-hg-path: implement more readable custom Debug for HgPath{,Buf}...
Martin von Zweigbergk -
r44360:4b3c8df1 default
parent child Browse files
Show More
@@ -77,7 +77,7 b' impl From<HgPathError> for std::io::Erro'
77 // `#[repr(transparent)]`.
77 // `#[repr(transparent)]`.
78 // Anyway, `Slice` representation and layout are considered implementation
78 // Anyway, `Slice` representation and layout are considered implementation
79 // detail, are not documented and must not be relied upon.
79 // detail, are not documented and must not be relied upon.
80 #[derive(Eq, Ord, PartialEq, PartialOrd, Debug, Hash)]
80 #[derive(Eq, Ord, PartialEq, PartialOrd, Hash)]
81 pub struct HgPath {
81 pub struct HgPath {
82 inner: [u8],
82 inner: [u8],
83 }
83 }
@@ -181,13 +181,19 b' impl HgPath {'
181 }
181 }
182 }
182 }
183
183
184 impl fmt::Debug for HgPath {
185 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
186 write!(f, "HgPath({:?})", String::from_utf8_lossy(&self.inner))
187 }
188 }
189
184 impl fmt::Display for HgPath {
190 impl fmt::Display for HgPath {
185 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
191 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
186 write!(f, "{}", String::from_utf8_lossy(&self.inner))
192 write!(f, "{}", String::from_utf8_lossy(&self.inner))
187 }
193 }
188 }
194 }
189
195
190 #[derive(Eq, Ord, Clone, PartialEq, PartialOrd, Debug, Hash)]
196 #[derive(Eq, Ord, Clone, PartialEq, PartialOrd, Hash)]
191 pub struct HgPathBuf {
197 pub struct HgPathBuf {
192 inner: Vec<u8>,
198 inner: Vec<u8>,
193 }
199 }
@@ -210,6 +216,12 b' impl HgPathBuf {'
210 }
216 }
211 }
217 }
212
218
219 impl fmt::Debug for HgPathBuf {
220 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
221 write!(f, "HgPathBuf({:?})", String::from_utf8_lossy(&self.inner))
222 }
223 }
224
213 impl fmt::Display for HgPathBuf {
225 impl fmt::Display for HgPathBuf {
214 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
226 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
215 write!(f, "{}", String::from_utf8_lossy(&self.inner))
227 write!(f, "{}", String::from_utf8_lossy(&self.inner))
General Comments 0
You need to be logged in to leave comments. Login now