--- a/rust/hg-core/src/lib.rs Tue Jan 26 19:07:24 2021 +0100
+++ b/rust/hg-core/src/lib.rs Tue Jan 26 20:05:37 2021 +0100
@@ -89,6 +89,7 @@
DirstatePackError::CorruptedEntry(e.to_string())
}
}
+
#[derive(Debug, PartialEq)]
pub enum DirstateMapError {
PathNotFound(HgPathBuf),
@@ -108,7 +109,7 @@
}
}
-#[derive(Debug)]
+#[derive(Debug, derive_more::From)]
pub enum DirstateError {
Parse(DirstateParseError),
Pack(DirstatePackError),
@@ -116,24 +117,14 @@
IO(std::io::Error),
}
-impl From<DirstateParseError> for DirstateError {
- fn from(e: DirstateParseError) -> Self {
- DirstateError::Parse(e)
- }
-}
-
-impl From<DirstatePackError> for DirstateError {
- fn from(e: DirstatePackError) -> Self {
- DirstateError::Pack(e)
- }
-}
-
-#[derive(Debug)]
+#[derive(Debug, derive_more::From)]
pub enum PatternError {
+ #[from]
Path(HgPathError),
UnsupportedSyntax(String),
UnsupportedSyntaxInFile(String, String, usize),
TooLong(usize),
+ #[from]
IO(std::io::Error),
/// Needed a pattern that can be turned into a regex but got one that
/// can't. This should only happen through programmer error.
@@ -163,27 +154,3 @@
}
}
}
-
-impl From<DirstateMapError> for DirstateError {
- fn from(e: DirstateMapError) -> Self {
- DirstateError::Map(e)
- }
-}
-
-impl From<std::io::Error> for DirstateError {
- fn from(e: std::io::Error) -> Self {
- DirstateError::IO(e)
- }
-}
-
-impl From<std::io::Error> for PatternError {
- fn from(e: std::io::Error) -> Self {
- PatternError::IO(e)
- }
-}
-
-impl From<HgPathError> for PatternError {
- fn from(e: HgPathError) -> Self {
- PatternError::Path(e)
- }
-}