pub trait FoldWithOption: Sized {
// Required method
fn fold_with<U>(
self,
opt: Option<U>,
f: impl FnOnce(Self, U) -> Self,
) -> Self;
}Available on crate feature
internal-api only.Expand description
Extension trait for folding zero or one value from an Option into a base value.
Required Methods§
Sourcefn fold_with<U>(self, opt: Option<U>, f: impl FnOnce(Self, U) -> Self) -> Self
fn fold_with<U>(self, opt: Option<U>, f: impl FnOnce(Self, U) -> Self) -> Self
Applies an optional fold operation f to self if opt is Some; otherwise returns
self.
Similar to opt.iter().fold(self, |acc, value| f(acc, value)), but accepting FnOnce
instead of requiring FnMut, and with the base value as receiver instead of the option.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".