mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03:00
Add a warning about Option/Result::and() being eagerly evaluated
Copied from `or()`.
This commit is contained in:
@@ -1189,6 +1189,12 @@ pub fn iter_mut(&mut self) -> IterMut<'_, T> {
|
||||
|
||||
/// Returns [`None`] if the option is [`None`], otherwise returns `optb`.
|
||||
///
|
||||
/// Arguments passed to `and` are eagerly evaluated; if you are passing the
|
||||
/// result of a function call, it is recommended to use [`and_then`], which is
|
||||
/// lazily evaluated.
|
||||
///
|
||||
/// [`and_then`]: Option::and_then
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
|
||||
@@ -1285,6 +1285,11 @@ pub fn into_err(self) -> E
|
||||
|
||||
/// Returns `res` if the result is [`Ok`], otherwise returns the [`Err`] value of `self`.
|
||||
///
|
||||
/// Arguments passed to `and` are eagerly evaluated; if you are passing the
|
||||
/// result of a function call, it is recommended to use [`and_then`], which is
|
||||
/// lazily evaluated.
|
||||
///
|
||||
/// [`and_then`]: Result::and_then
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user