mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Add flatmap
/flat_map
-> and_then
suggestions
This commit is contained in:
parent
caa216d245
commit
f566867ace
@ -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>,
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user