Impl Display for StoreId

This commit is contained in:
Matthias Beyer 2016-06-30 11:02:58 +02:00
parent 80a198523a
commit ea4487a481

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;