Skip to content

Commit 848af39

Browse files
committed
Add note to or_fun_call, list checked methods
1 parent 923d612 commit 848af39

File tree

1 file changed

+12
-2
lines changed
  • clippy_lints/src/methods

1 file changed

+12
-2
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,11 +1330,21 @@ declare_clippy_lint! {
13301330
}
13311331

13321332
declare_clippy_lint! {
1333-
/// **What it does:** Looks for unnecessary lazily evaluated closures on `Option` and `Result`.
1333+
/// **What it does:** As the counterpart to `or_fun_call`, this lint looks for unnecessary
1334+
/// lazily evaluated closures on `Option` and `Result`.
1335+
///
1336+
/// This lint suggests changing the following functions, when eager evaluation results in
1337+
/// simpler code:
1338+
/// - `unwrap_or_else` to `unwrap_or`
1339+
/// - `and_then` to `and`
1340+
/// - `or_else` to `or`
1341+
/// - `get_or_insert_with` to `get_or_insert`
1342+
/// - `ok_or_else` to `ok_or`
13341343
///
13351344
/// **Why is this bad?** Using eager evaluation is shorter and simpler in some cases.
13361345
///
1337-
/// **Known problems:** None.
1346+
/// **Known problems:** It is possible, but not recommended for `Deref` and `Index` to have
1347+
/// side effects. Eagerly evaluating them can change the semantics of the program.
13381348
///
13391349
/// **Example:**
13401350
///

0 commit comments

Comments
 (0)