Simplify a few pattern matches

A few pattern-matches correspond directly to standard combinators on
`Result`, `Option`. This uses them for concision / clarity.

Refactorings reviewed by the author after suggestion from [comby-rust](https://github.com/huitseeker/comby-rust).
This commit is contained in:
François Garillot 2021-01-28 15:40:07 -05:00
parent 6315f7dc28
commit 45f3f5a945
No known key found for this signature in database
GPG Key ID: A6EFBA9E3F33E320
2 changed files with 2 additions and 8 deletions

View File

@ -123,10 +123,7 @@ impl SaplingOutput {
value: Amount,
memo: Option<Memo>,
) -> Result<Self, Error> {
let g_d = match to.g_d() {
Some(g_d) => g_d,
None => return Err(Error::InvalidAddress),
};
let g_d = to.g_d().ok_or(Error::InvalidAddress)?;
if value.is_negative() {
return Err(Error::InvalidAmount);
}

View File

@ -429,10 +429,7 @@ impl ExtendedFullViewingKey {
}
pub fn address(&self, j: DiversifierIndex) -> Result<(DiversifierIndex, PaymentAddress), ()> {
let (j, d_j) = match self.dk.diversifier(j) {
Ok(ret) => ret,
Err(()) => return Err(()),
};
let (j, d_j) = self.dk.diversifier(j)?;
match self.fvk.vk.to_payment_address(d_j) {
Some(addr) => Ok((j, addr)),
None => Err(()),