chiark / gitweb /
display as debug
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jul 2020 11:59:57 +0000 (12:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jul 2020 11:59:57 +0000 (12:59 +0100)
src/error.rs
src/pieces.rs

index 454ad0f090d50c0b98a417d595c22aeed25f6a71..e52953b5f1a778d043f1a34b639e1d2b141674aa 100644 (file)
@@ -80,5 +80,11 @@ impl IdForById for PieceId {
 #[macro_export]
 macro_rules! display_as_debug {
   {$x:ty} => {
+    impl Display for $x {
+      fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+        <Self as Debug>::fmt(self, f)
+      }
+    }
   }
 }
+pub use crate::display_as_debug;
index 8173a6569e4aa77d96e3737b938c1a3d65547ff6..17e2acc27d3477ed818679545d8a939e2a411b50 100644 (file)
@@ -22,14 +22,10 @@ pub enum SVGProcessError {
   BadNumber,
   WriteFail,
 }
+display_as_debug!{SVGProcessError}
 impl From<fmt::Error> for SVGProcessError {
   fn from(_: fmt::Error) -> Self { SVGProcessError::WriteFail }
 }
-impl Display for SVGProcessError {
-  fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
-    <Self as Debug>::fmt(self, f)
-  }
-}
 
 #[throws(SVGProcessError)]
 pub fn svg_rescale_path(input: &str, scale: f64) -> String {