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

Method zip_with

ctutils/src/ct_option.rs:507–512  ·  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

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

Callers

nothing calls this directly

Calls 2

mapMethod · 0.80
zipMethod · 0.80

Tested by

no test coverage detected