MCPcopy Create free account
hub / github.com/RustCrypto/utils / zip_with

Method zip_with

ctutils/src/ct_option.rs:509–514  ·  view source on GitHub ↗

Zips `self` and another `CtOption` with function `f`. If `self.is_some() && other.is_some()`, this method returns a new [`CtOption`] for the result of `f` applied to their inner values where `is_some()` is [`Choice::TRUE`]. Otherwise, a [`CtOption`] where `is_some()` is [`Choice::FALSE`] is returned.

(self, other: CtOption<U>, f: F)

Source from the content-addressed store, hash-verified

507 ///
508 /// Otherwise, a [`CtOption`] where `is_some()` is [`Choice::FALSE`] is returned.
509 pub fn zip_with<U, F, R>(self, other: CtOption<U>, f: F) -> CtOption<R>
510 where
511 F: FnOnce(T, U) -> R,
512 {
513 self.zip(other).map(|(a, b)| f(a, b))
514 }
515}
516
517impl<T> CtOption<&T> {

Callers

nothing calls this directly

Calls 2

mapMethod · 0.80
zipMethod · 0.80

Tested by

no test coverage detected