Skip to content

Commit 40224f4

Browse files
committed
refactor: Put together an if statement
1 parent 9716a9e commit 40224f4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

clippy_lints/src/map_clone.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,11 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
143143
impl MapClone {
144144
fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
145145
let mut applicability = Applicability::MachineApplicable;
146-
let message = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
147-
"you are using an explicit closure for copying elements"
148-
} else {
149-
"you are using an explicit closure for cloning elements"
150-
};
151-
let sugg_method = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
152-
"copied"
146+
147+
let (message, sugg_method) = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
148+
("you are using an explicit closure for copying elements", "copied")
153149
} else {
154-
"cloned"
150+
("you are using an explicit closure for cloning elements", "cloned")
155151
};
156152

157153
span_lint_and_sugg(

0 commit comments

Comments
 (0)