Tracking Issue for `Option::reduce`
Open
Nobody has claimed this yet.
C-tracking-issue
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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.)
- Implementation: #144274
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Will this cause inference problems? https://github.com/rust-lang/libs-team/issues/609#issuecomment-3026494590
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading implementation issue #144274 and the ACP discussion in rust-lang/libs-team#609, then review the unresolved inference question. The feature is done only when the final comment period and stabilization PR have been completed and the option_reduce gate can be stabilized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100