Reimplement StoreId::to_str() without erroring

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-11-26 18:13:12 +01:00
parent 49b0b3a414
commit dd388e53bb

View file

@ -120,15 +120,10 @@ impl StoreId {
} }
pub fn to_str(&self) -> Result<String> { pub fn to_str(&self) -> Result<String> {
self.base match self.base.as_ref() {
.as_ref() None => Ok(self.id.display().to_string()),
.cloned() Some(ref base) => Ok(format!("{}/{}", base.display(), self.id.display())),
.map(|mut base| { base.push(self.id.clone()); base }) }
.unwrap_or_else(|| self.id.clone())
.to_str()
.map(String::from)
.ok_or_else(|| err_msg("Store ID Handling error"))
.map_err(Error::from)
} }
/// Helper function for creating a displayable String from StoreId /// Helper function for creating a displayable String from StoreId