Reimplement StoreId::to_str() to remove unwrap()
This commit is contained in:
parent
52367edc83
commit
3d572dda0f
1 changed files with 8 additions and 10 deletions
|
@ -95,16 +95,14 @@ impl StoreId {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_str(&self) -> Result<String> {
|
pub fn to_str(&self) -> Result<String> {
|
||||||
if self.base.is_some() {
|
self.base
|
||||||
let mut base = self.base.as_ref().cloned().unwrap();
|
.as_ref()
|
||||||
base.push(self.id.clone());
|
.cloned()
|
||||||
base
|
.map(|mut base| { base.push(self.id.clone()); base })
|
||||||
} else {
|
.unwrap_or_else(|| self.id.clone())
|
||||||
self.id.clone()
|
.to_str()
|
||||||
}
|
.map(String::from)
|
||||||
.to_str()
|
.ok_or(SEK::StoreIdHandlingError.into_error())
|
||||||
.map(String::from)
|
|
||||||
.ok_or(SEK::StoreIdHandlingError.into_error())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the components of the `id` part of the StoreId object.
|
/// Returns the components of the `id` part of the StoreId object.
|
||||||
|
|
Loading…
Reference in a new issue