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! {
32903290 /// Checks for usage of `Iterator::fold` with a type that implements `Try`.
32913291 ///
32923292 /// ### 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.
32973302 ///
32983303 /// ### Example
32993304 /// ```rust
You can’t perform that action at this time.
0 commit comments