File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -3290,10 +3290,15 @@ declare_clippy_lint! {
3290
3290
/// Checks for usage of `Iterator::fold` with a type that implements `Try`.
3291
3291
///
3292
3292
/// ### Why is this bad?
3293
- /// This is better represented with `try_fold`, but this has one major difference: It will
3294
- /// short-circuit on failure. *This is almost always what you want*. This can also open the door
3295
- /// for additional optimizations as well, as rustc can guarantee the function is never
3296
- /// called on `None`, `Err`, etc., alleviating otherwise necessary checks.
3293
+ /// This should use `try_fold` instead, which short-circuits on failure, thus opening the door
3294
+ /// for additional optimizations not possible with `fold` as rustc can guarantee the function is
3295
+ /// never called on `None`, `Err`, etc., alleviating otherwise necessary checks. It's also
3296
+ /// slightly more idiomatic.
3297
+ ///
3298
+ /// ### Known issues
3299
+ /// This lint doesn't take into account whether a function does something on the failure case,
3300
+ /// i.e., whether short-circuiting will affect behavior. Refactoring to `try_fold` is not
3301
+ /// desirable in those cases.
3297
3302
///
3298
3303
/// ### Example
3299
3304
/// ```rust
You can’t perform that action at this time.
0 commit comments