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.

ACP: rust-lang/libs-team#609

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.)

Unresolved Questions

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html