Merge pull request #487 from matthiasbeyer/libimagstore/storeid-display

Impl Display for StoreId
This commit is contained in:
Matthias Beyer 2016-07-04 19:26:15 +02:00 committed by GitHub
commit 93ef146fff
1 changed files with 12 additions and 1 deletions

View File

@ -4,7 +4,7 @@ use std::borrow::Borrow;
use std::ops::Deref; use std::ops::Deref;
use semver::Version; use semver::Version;
use std::fmt::{Debug, Formatter}; use std::fmt::{Display, Debug, Formatter};
use std::fmt::Error as FmtError; use std::fmt::Error as FmtError;
use std::result::Result as RResult; use std::result::Result as RResult;
@ -24,6 +24,17 @@ impl Into<PathBuf> for StoreId {
} }
impl Display for StoreId {
fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> {
match self.0.to_str() {
Some(s) => write!(fmt, "{}", s),
None => write!(fmt, "<non-UTF8-StoreId>"), // TODO: Sure here?
}
}
}
impl Deref for StoreId { impl Deref for StoreId {
type Target = PathBuf; type Target = PathBuf;