Skip to content

Commit 896a081

Browse files
committed
use find(x) instead of filter(x).next()
1 parent a8437cf commit 896a081

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

src/librustc/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl RegionHighlightMode {
136136
pub fn highlighting_region(&mut self, region: ty::Region<'_>, number: usize) {
137137
let num_slots = self.highlight_regions.len();
138138
let first_avail_slot =
139-
self.highlight_regions.iter_mut().filter(|s| s.is_none()).next().unwrap_or_else(|| {
139+
self.highlight_regions.iter_mut().find(|s| s.is_none()).unwrap_or_else(|| {
140140
bug!("can only highlight {} placeholders at a time", num_slots,)
141141
});
142142
*first_avail_slot = Some((*region, number));

src/librustc_infer/traits/coherence.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ fn orphan_check_trait_ref<'tcx>(
399399
let local_type = trait_ref
400400
.input_types()
401401
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
402-
.filter(|ty| ty_is_non_local_constructor(ty, in_crate).is_none())
403-
.next();
402+
.find(|ty| ty_is_non_local_constructor(ty, in_crate).is_none());
404403

405404
debug!("orphan_check_trait_ref: uncovered ty local_type: `{:?}`", local_type);
406405

src/librustc_infer/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ pub fn suggest_constraining_type_param(
14421442
const MSG_RESTRICT_TYPE: &str = "consider restricting this type parameter with";
14431443
const MSG_RESTRICT_TYPE_FURTHER: &str = "consider further restricting this type parameter with";
14441444

1445-
let param = generics.params.iter().filter(|p| p.name.ident().as_str() == param_name).next();
1445+
let param = generics.params.iter().find(|p| p.name.ident().as_str() == param_name);
14461446

14471447
let param = if let Some(param) = param {
14481448
param

src/librustc_parse/lexer/tokentrees.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,15 @@ impl<'a> TokenTreesReader<'a> {
9393
}
9494

9595
if let Some((delim, _)) = self.open_braces.last() {
96-
if let Some((_, open_sp, close_sp)) = self
97-
.matching_delim_spans
98-
.iter()
99-
.filter(|(d, open_sp, close_sp)| {
96+
if let Some((_, open_sp, close_sp)) =
97+
self.matching_delim_spans.iter().find(|(d, open_sp, close_sp)| {
10098
if let Some(close_padding) = sm.span_to_margin(*close_sp) {
10199
if let Some(open_padding) = sm.span_to_margin(*open_sp) {
102100
return delim == d && close_padding != open_padding;
103101
}
104102
}
105103
false
106104
})
107-
.next()
108105
// these are in reverse order as they get inserted on close, but
109106
{
110107
// we want the last open/first close

src/librustc_parse/parser/expr.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,8 @@ impl<'a> Parser<'a> {
225225

226226
// Make sure that the span of the parent node is larger than the span of lhs and rhs,
227227
// including the attributes.
228-
let lhs_span = lhs
229-
.attrs
230-
.iter()
231-
.filter(|a| a.style == AttrStyle::Outer)
232-
.next()
233-
.map_or(lhs_span, |a| a.span);
228+
let lhs_span =
229+
lhs.attrs.iter().find(|a| a.style == AttrStyle::Outer).map_or(lhs_span, |a| a.span);
234230
let span = lhs_span.to(rhs.span);
235231
lhs = match op {
236232
AssocOp::Add

src/librustdoc/clean/types.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,7 @@ impl Attributes {
565565

566566
let inner_docs = attrs
567567
.iter()
568-
.filter(|a| a.doc_str().is_some())
569-
.next()
568+
.find(|a| a.doc_str().is_some())
570569
.map_or(true, |a| a.style == AttrStyle::Inner);
571570

572571
Attributes {

0 commit comments

Comments
 (0)