Feature gate: #![feature(option_reduce)]
This is a tracking issue for Option::reduce, which combines two Options into one if both are Some, otherwise choosing the one that's Some or returning None.
ACP: rust-lang/libs-team#609
Public API
impl<T> Option<T> {
fn reduce<U, R, F>(self, other: Option<U>, f: F) -> Option<R>
where
T: Into<R>,
U: Into<R>,
F: FnOnce(T, U) -> R,
{
match (self, other) {
(Some(a), Some(b)) => Some(f(a, b)),
(Some(a), _) => Some(a.into()),
(_, Some(b)) => Some(b.into()),
_ => None,
}
}
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
Unresolved Questions
Feature gate:
#![feature(option_reduce)]This is a tracking issue for
Option::reduce, which combines twoOptions into one if both areSome, otherwise choosing the one that'sSomeor returningNone.ACP: rust-lang/libs-team#609
Public API
Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩