Skip to content

Commit

Permalink
refactor: Put together an if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoto7250 committed Apr 12, 2022
1 parent 9716a9e commit 40224f4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 40224f4

Please sign in to comment.