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,13 +95,11 @@ 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()
|
||||
}
|
||||
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())
|
||||
|
|
Loading…
Reference in a new issue