refactor: use map_err

This commit is contained in:
Joonas Koivunen 2020-06-11 18:57:35 +03:00
parent f935c7bc72
commit 42fd182df7

View File

@ -28,11 +28,7 @@ pub fn nameless_links(
.enumerate()
.map(|(nth, link)| {
let hash = link.Hash.as_deref().unwrap_or_default();
match Cid::try_from(hash) {
Ok(cid) => Ok(cid),
Err(e) => Err(InvalidCidInLink::from((nth, link, e))),
}
Cid::try_from(hash).map_err(|e| InvalidCidInLink::from((nth, link, e)))
})
.collect::<Result<Vec<_>, _>>())
}