From 5d11375f9451e766f1b9e627c5a4e8c76c570084 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 3 Jan 2016 16:19:46 +0100 Subject: [PATCH] (Re)implement Display for FileID, FileHash, FileIDType --- src/storage/file/id.rs | 4 +--- src/storage/file/id_type.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index 6d239381..0096fad3 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -108,9 +108,7 @@ impl Debug for FileID { impl Display for FileID { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - try!(write!(fmt, "FileID[{:?}]: {:?}", - self.id_type, - self.id)); + try!(write!(fmt, "{}-{}", self.id_type, self.id)); Ok(()) } diff --git a/src/storage/file/id_type.rs b/src/storage/file/id_type.rs index dbb498b6..06c6a1c7 100644 --- a/src/storage/file/id_type.rs +++ b/src/storage/file/id_type.rs @@ -1,3 +1,5 @@ +use std::fmt::{Debug, Display, Formatter}; +use std::fmt; use std::convert::{From, Into}; use std::str::FromStr; @@ -5,7 +7,6 @@ use std::str::FromStr; #[derive(Clone)] #[derive(PartialEq)] #[derive(Eq)] -// #[derive(Display)] #[derive(Hash)] /** * File ID type @@ -39,3 +40,13 @@ impl Into for FileIDType { } } +impl Display for FileIDType { + + fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + match self { + &FileIDType::UUID => try!(write!(fmt, "UUID")), + } + Ok(()) + } +} +