From: Ian Jackson Date: Sun, 12 Jul 2020 11:59:57 +0000 (+0100) Subject: display as debug X-Git-Tag: otter-0.2.0~1364 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3cb8be3ab3d58f59d3aa38bf40ccb744788a3050;p=otter.git display as debug --- diff --git a/src/error.rs b/src/error.rs index 454ad0f0..e52953b5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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> { + ::fmt(self, f) + } + } } } +pub use crate::display_as_debug; diff --git a/src/pieces.rs b/src/pieces.rs index 8173a656..17e2acc2 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -22,14 +22,10 @@ pub enum SVGProcessError { BadNumber, WriteFail, } +display_as_debug!{SVGProcessError} impl From for SVGProcessError { fn from(_: fmt::Error) -> Self { SVGProcessError::WriteFail } } -impl Display for SVGProcessError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - ::fmt(self, f) - } -} #[throws(SVGProcessError)] pub fn svg_rescale_path(input: &str, scale: f64) -> String {