Closed
Description
Feature gate: #![feature(is_some_and)]
This is a tracking issue for Option::is_some_and
, Result::is_ok_and
and Result::is_err_and
.
Public API
impl<T> Option<T> {
pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool;
}
impl<T, E> Result<T, E> {
pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool;
pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool;
}
Steps / History
- Lots of discussion and bikeshedding starting here: Tracking issue for
Option::contains
andResult::contains
#62358 (comment) - Implementation: Add Option::is_some_with and Result::is_{ok,err}_with #93051
- Rename: Rename is_{some,ok,err}_with to is_{some,ok,err}_and. #94765
- Take
self
by value: Changeis_some_and
to take by value #98354 - Final comment period (FCP)
- Stabilization PR: Stabilize is_some_and #110019
Unresolved Questions
- Naming. Alternatives:
is_some_with
/is_ok_with
/is_err_with
- ➡️
is_some_and
/is_ok_and
/is_err_and
contains
/contains_err
and_is
/and_err_is
is
has
- Take
self
or&self
?