From a63b7315d030b91228b7ae148a55fd3985a21376 Mon Sep 17 00:00:00 2001 From: Don Rowe Date: Mon, 3 Oct 2016 21:18:29 -0700 Subject: [PATCH] Implement Display trait for CompressionMethod. It's an alias to the Debug format, but we can't derive Display yet, so we associate it explicitly. --- src/compression.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compression.rs b/src/compression.rs index 927fc9e1..4581bfbf 100644 --- a/src/compression.rs +++ b/src/compression.rs @@ -1,5 +1,7 @@ //! Possible ZIP compression methods. +use std::fmt; + /// Compression methods for the contents of a ZIP file. #[derive(Copy, Clone, PartialEq, Debug)] pub enum CompressionMethod @@ -39,6 +41,13 @@ impl CompressionMethod { } } +impl fmt::Display for CompressionMethod { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Just duplicate what the Debug format looks like, i.e, the enum key: + write!(f, "{:?}", self) + } +} + #[cfg(test)] mod test { use super::CompressionMethod;