Some simple Option / Result / iterator pattern simplifications (#3205)
This commit is contained in:
committed by
GitHub
parent
616dad43fd
commit
dcdbdd4bcc
@@ -463,10 +463,7 @@ impl KernelHandler {
|
||||
height,
|
||||
mmr_index,
|
||||
});
|
||||
match kernel {
|
||||
Some(kernel) => Ok(kernel),
|
||||
None => Err(ErrorKind::NotFound.into()),
|
||||
}
|
||||
kernel.ok_or_else(|| ErrorKind::NotFound.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -334,10 +334,10 @@ impl OutputPrintable {
|
||||
}
|
||||
|
||||
pub fn range_proof(&self) -> Result<pedersen::RangeProof, ser::Error> {
|
||||
let proof_str = match self.proof.clone() {
|
||||
Some(p) => p,
|
||||
None => return Err(ser::Error::HexError(format!("output range_proof missing"))),
|
||||
};
|
||||
let proof_str = self
|
||||
.proof
|
||||
.clone()
|
||||
.ok_or_else(|| ser::Error::HexError(format!("output range_proof missing")))?;
|
||||
|
||||
let p_vec = util::from_hex(proof_str)
|
||||
.map_err(|_| ser::Error::HexError(format!("invalid output range_proof")))?;
|
||||
|
||||
+1
-4
@@ -105,10 +105,7 @@ impl QueryParams {
|
||||
}
|
||||
|
||||
pub fn get(&self, name: &str) -> Option<&String> {
|
||||
match self.params.get(name) {
|
||||
None => None,
|
||||
Some(v) => v.first(),
|
||||
}
|
||||
self.params.get(name).and_then(|v| v.first())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user