Add flatmap/flat_map -> and_then suggestions

This commit is contained in:
Esteban Küber 2024-02-14 16:04:40 +00:00
parent caa216d245
commit f566867ace
2 changed files with 2 additions and 0 deletions

View File

@ -1403,6 +1403,7 @@ impl<T> Option<T> {
#[doc(alias = "flatmap")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_confusables("flat_map", "flatmap")]
pub fn and_then<U, F>(self, f: F) -> Option<U>
where
F: FnOnce(T) -> Option<U>,

View File

@ -1315,6 +1315,7 @@ impl<T, E> Result<T, E> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_confusables("flat_map", "flatmap")]
pub fn and_then<U, F: FnOnce(T) -> Result<U, E>>(self, op: F) -> Result<U, E> {
match self {
Ok(t) => op(t),