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.
This commit is contained in:
Don Rowe 2016-10-03 21:18:29 -07:00
parent b1f7a49337
commit a63b7315d0

View file

@ -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;