Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/utils/hg_path.rs @ 46435:2e2033081274
rust: replace trivial `impl From ?` with `#[derive(derive_more::From)]`
Crate docs: https://jeltef.github.io/derive_more/derive_more/from.html
Differential Revision: https://phab.mercurial-scm.org/D9875
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 26 Jan 2021 20:05:37 +0100 |
parents | 2d5dfc8fed55 |
children | 6c778d20c8c2 |
comparison
equal
deleted
inserted
replaced
46434:3e2d539d0d1a | 46435:2e2033081274 |
---|---|
365 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 365 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
366 write!(f, "{}", String::from_utf8_lossy(&self.inner)) | 366 write!(f, "{}", String::from_utf8_lossy(&self.inner)) |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 #[derive(Default, Eq, Ord, Clone, PartialEq, PartialOrd, Hash)] | 370 #[derive( |
371 Default, Eq, Ord, Clone, PartialEq, PartialOrd, Hash, derive_more::From, | |
372 )] | |
371 pub struct HgPathBuf { | 373 pub struct HgPathBuf { |
372 inner: Vec<u8>, | 374 inner: Vec<u8>, |
373 } | 375 } |
374 | 376 |
375 impl HgPathBuf { | 377 impl HgPathBuf { |
403 type Target = HgPath; | 405 type Target = HgPath; |
404 | 406 |
405 #[inline] | 407 #[inline] |
406 fn deref(&self) -> &HgPath { | 408 fn deref(&self) -> &HgPath { |
407 &HgPath::new(&self.inner) | 409 &HgPath::new(&self.inner) |
408 } | |
409 } | |
410 | |
411 impl From<Vec<u8>> for HgPathBuf { | |
412 fn from(vec: Vec<u8>) -> Self { | |
413 Self { inner: vec } | |
414 } | 410 } |
415 } | 411 } |
416 | 412 |
417 impl<T: ?Sized + AsRef<HgPath>> From<&T> for HgPathBuf { | 413 impl<T: ?Sized + AsRef<HgPath>> From<&T> for HgPathBuf { |
418 fn from(s: &T) -> HgPathBuf { | 414 fn from(s: &T) -> HgPathBuf { |