aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-05-13 21:15:52 +0200
committerHampusM <hampus@hampusmat.com>2023-05-13 21:15:52 +0200
commit1ffc8cbafc4439435307831e87d6f3c265ad819c (patch)
tree6d080deda22bc9c467672f60256024d68dabe3e9 /examples
parentbdce3a36f72de6097fb78a917e29b7e093a6ef58 (diff)
feat: add deserializer error conversion utilities
Diffstat (limited to 'examples')
-rw-r--r--examples/simple.rs26
1 files changed, 3 insertions, 23 deletions
diff --git a/examples/simple.rs b/examples/simple.rs
index a4b76f2..563530c 100644
--- a/examples/simple.rs
+++ b/examples/simple.rs
@@ -8,7 +8,7 @@ use std::path::Path;
use xml_stinks::deserializer::buffered::Buffered as BufferedDeserializer;
use xml_stinks::deserializer::{Deserializer, Error as DeserializerError, IgnoreEnd};
use xml_stinks::tagged::TagStart;
-use xml_stinks::DeserializeTagged;
+use xml_stinks::{impl_from_deserializer_error, DeserializeTagged};
const MANIFEST_DIR: &str = std::env!("CARGO_MANIFEST_DIR");
@@ -81,17 +81,7 @@ enum DataError
DeserializeFailed(#[from] DeserializerError<Infallible>),
}
-impl<DeError: Into<Self>> From<DeserializerError<DeError>> for DataError
-{
- fn from(err: DeserializerError<DeError>) -> Self
- {
- if let DeserializerError::DeserializeFailed(de_err) = err {
- return de_err.into();
- }
-
- err.into_never_de_err().into()
- }
-}
+impl_from_deserializer_error!(DataError);
#[derive(Debug)]
struct Favorites
@@ -130,14 +120,4 @@ enum FavoritesError
DeserializeFailed(#[from] DeserializerError<Infallible>),
}
-impl<DeError: Into<Self>> From<DeserializerError<DeError>> for FavoritesError
-{
- fn from(err: DeserializerError<DeError>) -> Self
- {
- if let DeserializerError::DeserializeFailed(de_err) = err {
- return de_err.into();
- }
-
- err.into_never_de_err().into()
- }
-}
+impl_from_deserializer_error!(FavoritesError);