summaryrefslogtreecommitdiffstats
path: root/libimagstore
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-10-13 14:31:32 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-10-15 15:49:00 +0200
commit3d572dda0f4458cee3833350b8f6907c7422cc12 (patch)
treee348503e0243c806ce488216aa78dea159f6d250 /libimagstore
parent52367edc83d87221826253e0c50b82a2f65c44f7 (diff)
Reimplement StoreId::to_str() to remove unwrap()
Diffstat (limited to 'libimagstore')
-rw-r--r--libimagstore/src/storeid.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs
index 5f979126..8a3623c8 100644
--- a/libimagstore/src/storeid.rs
+++ b/libimagstore/src/storeid.rs
@@ -95,16 +95,14 @@ impl StoreId {
}
pub fn to_str(&self) -> Result<String> {
- if self.base.is_some() {
- let mut base = self.base.as_ref().cloned().unwrap();
- base.push(self.id.clone());
- base
- } else {
- self.id.clone()
- }
- .to_str()
- .map(String::from)
- .ok_or(SEK::StoreIdHandlingError.into_error())
+ 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(SEK::StoreIdHandlingError.into_error())
}
/// Returns the components of the `id` part of the StoreId object.