diff options
| author | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2022-04-12 09:49:00 +0900 |
|---|---|---|
| committer | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2022-04-12 09:49:00 +0900 |
| commit | 40224f46c0158ff8bf6657f2272dba9ec2ee96d7 (patch) | |
| tree | 4298a1b0ffc210cd1d280567a043431d6473cfcb | |
| parent | 9716a9eff0d68c92fd064b293f0ffbd083645fa5 (diff) | |
| download | rust-40224f46c0158ff8bf6657f2272dba9ec2ee96d7.tar.gz rust-40224f46c0158ff8bf6657f2272dba9ec2ee96d7.zip | |
refactor: Put together an if statement
| -rw-r--r-- | clippy_lints/src/map_clone.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index a03d5d54065..ceb66947d02 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -143,15 +143,11 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) { impl MapClone { fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) { let mut applicability = Applicability::MachineApplicable; - let message = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) { - "you are using an explicit closure for copying elements" - } else { - "you are using an explicit closure for cloning elements" - }; - let sugg_method = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) { - "copied" + + let (message, sugg_method) = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) { + ("you are using an explicit closure for copying elements", "copied") } else { - "cloned" + ("you are using an explicit closure for cloning elements", "cloned") }; span_lint_and_sugg( |
