(Re)implement Display for FileID, FileHash, FileIDType

This commit is contained in:
Matthias Beyer 2016-01-03 16:19:46 +01:00
parent 670f0e16e9
commit 5d11375f94
2 changed files with 13 additions and 4 deletions

View file

@ -108,9 +108,7 @@ impl Debug for FileID {
impl Display for FileID { impl Display for FileID {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
try!(write!(fmt, "FileID[{:?}]: {:?}", try!(write!(fmt, "{}-{}", self.id_type, self.id));
self.id_type,
self.id));
Ok(()) Ok(())
} }

View file

@ -1,3 +1,5 @@
use std::fmt::{Debug, Display, Formatter};
use std::fmt;
use std::convert::{From, Into}; use std::convert::{From, Into};
use std::str::FromStr; use std::str::FromStr;
@ -5,7 +7,6 @@ use std::str::FromStr;
#[derive(Clone)] #[derive(Clone)]
#[derive(PartialEq)] #[derive(PartialEq)]
#[derive(Eq)] #[derive(Eq)]
// #[derive(Display)]
#[derive(Hash)] #[derive(Hash)]
/** /**
* File ID type * File ID type
@ -39,3 +40,13 @@ impl Into<String> for FileIDType {
} }
} }
impl Display for FileIDType {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
match self {
&FileIDType::UUID => try!(write!(fmt, "UUID")),
}
Ok(())
}
}