Skip to content

Commit 8a28d97

Browse files
committed
edit to use map_while
1 parent ac5527f commit 8a28d97

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

clippy_lints/src/large_enum_variant.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,25 @@ impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
139139
.fields_size
140140
.iter()
141141
.rev()
142-
.take_while(|val| {
143-
let judge = difference > self.maximum_size_difference_allowed;
144-
difference = difference.saturating_sub(val.size);
145-
judge
146-
})
147-
.map(|val| {
148-
(
149-
fields[val.ind].ty.span,
150-
format!(
151-
"Box<{}>",
152-
snippet_with_applicability(
153-
cx,
154-
fields[val.ind].ty.span,
155-
"..",
156-
&mut applicability
157-
)
158-
.into_owned()
159-
),
160-
)
142+
.map_while(|val| {
143+
if difference > self.maximum_size_difference_allowed {
144+
difference = difference.saturating_sub(val.size);
145+
Some((
146+
fields[val.ind].ty.span,
147+
format!(
148+
"Box<{}>",
149+
snippet_with_applicability(
150+
cx,
151+
fields[val.ind].ty.span,
152+
"..",
153+
&mut applicability
154+
)
155+
.into_owned()
156+
),
157+
))
158+
} else {
159+
None
160+
}
161161
})
162162
.collect();
163163

clippy_lints/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(box_patterns)]
44
#![feature(drain_filter)]
55
#![feature(in_band_lifetimes)]
6+
#![feature(iter_map_while)]
67
#![feature(iter_zip)]
78
#![feature(once_cell)]
89
#![feature(rustc_private)]

0 commit comments

Comments
 (0)