Reimplement StoreId::to_str() without erroring
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
49b0b3a414
commit
dd388e53bb
1 changed files with 4 additions and 9 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue