]> git.lizzy.rs Git - rust.git/commitdiff
Add note to `or_fun_call`, list checked methods
authorDániel Buga <bugadani@gmail.com>
Mon, 15 Jun 2020 12:55:23 +0000 (14:55 +0200)
committerDániel Buga <bugadani@gmail.com>
Sun, 16 Aug 2020 18:27:54 +0000 (20:27 +0200)
clippy_lints/src/methods/mod.rs

index 61b7f2647ee72c390c23e986cfd4fd99ac93c807..c672ca41decb4a8c68002f51e2f7f39df76a5e8a 100644 (file)
 }
 
 declare_clippy_lint! {
-    /// **What it does:** Looks for unnecessary lazily evaluated closures on `Option` and `Result`.
+    /// **What it does:** As the counterpart to `or_fun_call`, this lint looks for unnecessary
+    /// lazily evaluated closures on `Option` and `Result`.
+    ///
+    /// This lint suggests changing the following functions, when eager evaluation results in
+    /// simpler code:
+    ///  - `unwrap_or_else` to `unwrap_or`
+    ///  - `and_then` to `and`
+    ///  - `or_else` to `or`
+    ///  - `get_or_insert_with` to `get_or_insert`
+    ///  - `ok_or_else` to `ok_or`
     ///
     /// **Why is this bad?** Using eager evaluation is shorter and simpler in some cases.
     ///
-    /// **Known problems:** None.
+    /// **Known problems:** It is possible, but not recommended for `Deref` and `Index` to have
+    /// side effects. Eagerly evaluating them can change the semantics of the program.
     ///
     /// **Example:**
     ///