diff rust/rhg/src/error.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 3e2d539d0d1a
children 252d1bdba33d
line wrap: on
line diff
--- a/rust/rhg/src/error.rs	Tue Jan 26 19:07:24 2021 +0100
+++ b/rust/rhg/src/error.rs	Tue Jan 26 20:05:37 2021 +0100
@@ -8,13 +8,14 @@
 use std::path::PathBuf;
 
 /// The kind of command error
-#[derive(Debug)]
+#[derive(Debug, derive_more::From)]
 pub enum CommandError {
     /// The root of the repository cannot be found
     RootNotFound(PathBuf),
     /// The current directory cannot be found
     CurrentDirNotFound(std::io::Error),
     /// `.hg/requires`
+    #[from]
     RequirementsError(RequirementsError),
     /// The standard output stream cannot be written to
     StdoutError,
@@ -93,9 +94,3 @@
         }
     }
 }
-
-impl From<RequirementsError> for CommandError {
-    fn from(err: RequirementsError) -> Self {
-        CommandError::RequirementsError(err)
-    }
-}