summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-11-26 18:13:12 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-11-26 18:15:08 +0100
commitdd388e53bb317c45eaa64b927e5cd84b3be6a3e3 (patch)
treefa70eb27317bf3319e00e3dc6dc65a44ff033d87
parent49b0b3a4141338f291e7522b6970173c5970489d (diff)
downloadimag-dd388e53bb317c45eaa64b927e5cd84b3be6a3e3.zip
imag-dd388e53bb317c45eaa64b927e5cd84b3be6a3e3.tar.gz
Reimplement StoreId::to_str() without erroring
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/core/libimagstore/src/storeid.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs
index dbb061d..c783e14 100644
--- a/lib/core/libimagstore/src/storeid.rs
+++ b/lib/core/libimagstore/src/storeid.rs
@@ -120,15 +120,10 @@ impl StoreId {
}
pub fn to_str(&self) -> Result<String> {
- self.base
- .as_ref()
- .cloned()
- .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)
+ match self.base.as_ref() {
+ None => Ok(self.id.display().to_string()),
+ Some(ref base) => Ok(format!("{}/{}", base.display(), self.id.display())),
+ }
}
/// Helper function for creating a displayable String from StoreId