[bssl] Replace ok_or with ok_or_else in bssl for lazy evaluation
Prior to the cl, the bssl library used `ok_or` in a way that
resulted in the evaluation of the argument even when no error
occurred.
This cl replaces `ok_or` with `ok_or_else` to introduce lazy
evaluation in the error case.
Test: atest rialto_test
Change-Id: Ib9c514b577f68dc6da3cb00251ac88223c7a0402
diff --git a/libs/bssl/src/digest.rs b/libs/bssl/src/digest.rs
index 8a51b11..42d23d9 100644
--- a/libs/bssl/src/digest.rs
+++ b/libs/bssl/src/digest.rs
@@ -121,7 +121,7 @@
pub fn new() -> Result<Self> {
// SAFETY: The returned pointer is checked below.
let ctx = unsafe { EVP_MD_CTX_new() };
- NonNull::new(ctx).map(Self).ok_or(to_call_failed_error(ApiName::EVP_MD_CTX_new))
+ NonNull::new(ctx).map(Self).ok_or_else(|| to_call_failed_error(ApiName::EVP_MD_CTX_new))
}
pub(crate) fn as_mut_ptr(&mut self) -> *mut EVP_MD_CTX {