Auto merge of #50 - matthiasbeyer:better-output, r=matthiasbeyer

(Re)implement Display for FileID, FileHash, FileIDType

Improve output (Implementation of the `Display` trait).
This commit is contained in:
Homu 2016-01-04 00:21:14 +09:00
commit 9169d85c07
2 changed files with 13 additions and 4 deletions

View file

@ -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(())
}

View file

@ -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<String> for FileIDType {
}
}
impl Display for FileIDType {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
match self {
&FileIDType::UUID => try!(write!(fmt, "UUID")),
}
Ok(())
}
}