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:
parent
6315f7dc28
commit
45f3f5a945
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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(()),
|
||||
|
|
Loading…
Reference in New Issue