Tracking Issue for Option::reduce (original) (raw)
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.
Public API
impl Option { fn reduce<U, R, F>(self, other: Option, f: F) -> Option where T: Into, U: Into, 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.)
- Implementation: add Option::reduce #144274
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Will this cause inference problems? ACP: Add Option::reduce libs-team#609 (comment)