Replace complex unwrapping with big match block
This commit is contained in:
parent
c099fc7270
commit
29be4029da
1 changed files with 13 additions and 19 deletions
|
@ -137,25 +137,19 @@ fn add_foreign_link(target: &mut Entry, from: StoreId) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_rw_result(links: StoreResult<Option<Value>>) -> Result<Vec<Link>> {
|
fn process_rw_result(links: StoreResult<Option<Value>>) -> Result<Vec<Link>> {
|
||||||
if links.is_err() {
|
let links = match links {
|
||||||
|
Err(e) => {
|
||||||
debug!("RW action on store failed. Generating LinkError");
|
debug!("RW action on store failed. Generating LinkError");
|
||||||
return Err(LEK::EntryHeaderReadError.into_error_with_cause(Box::new(links.unwrap_err())))
|
return Err(LEK::EntryHeaderReadError.into_error_with_cause(Box::new(e)))
|
||||||
}
|
},
|
||||||
let links = links.unwrap();
|
Ok(None) => {
|
||||||
|
|
||||||
if links.is_none() {
|
|
||||||
debug!("We got no value from the header!");
|
debug!("We got no value from the header!");
|
||||||
return Ok(vec![])
|
return Ok(vec![])
|
||||||
}
|
},
|
||||||
let links = links.unwrap();
|
Ok(Some(Value::Array(l))) => l,
|
||||||
|
Ok(Some(_)) => {
|
||||||
let links = {
|
|
||||||
match links {
|
|
||||||
Value::Array(a) => a,
|
|
||||||
_ => {
|
|
||||||
debug!("We expected an Array for the links, but there was a non-Array!");
|
debug!("We expected an Array for the links, but there was a non-Array!");
|
||||||
return Err(LEK::ExistingLinkTypeWrong.into());
|
return Err(LEK::ExistingLinkTypeWrong.into());
|
||||||
},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue