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

Method map_or

ctutils/src/ct_option.rs:330–336  ·  view source on GitHub ↗
(self, default: U, f: F)

Source from the content-addressed store, hash-verified

328 #[inline]
329 #[must_use = "if you don't need the returned value, use `if let` instead"]
330 pub fn map_or<U, F>(self, default: U, f: F) -> U
331 where
332 U: CtSelect,
333 F: FnOnce(T) -> U,
334 {
335 self.map(f).unwrap_or(default)
336 }
337
338 /// Maps a `CtOption<T>` to a `U` value, eagerly evaluating the provided function, precomputing
339 /// `U::default()` using the [`Default`] trait, and returning it in the event `self.is_some()`

Callers 1

map_or_defaultMethod · 0.80

Calls 2

unwrap_orMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected