Skip to content

Commit a9b3e85

Browse files
authored
Rollup merge of rust-lang#77514 - scottmcm:less-once-chain-once, r=estebank
Replace some once(x).chain(once(y)) with [x, y] IntoIter Now that we have by-value array iterators that are [already used](https://github.com/rust-lang/rust/blob/25c8c53dd994acb3f4f7c02fe6bb46076393f8b0/compiler/rustc_hir/src/def.rs#L305-L307)... For example, ```diff - once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it) + IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it) ```
2 parents 5d4dbf9 + a32be12 commit a9b3e85

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

alloc/src/collections/vec_deque.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
// ignore-tidy-filelength
1111

12+
use core::array;
1213
use core::cmp::{self, Ordering};
1314
use core::fmt;
1415
use core::hash::{Hash, Hasher};
15-
use core::iter::{once, repeat_with, FromIterator, FusedIterator};
16+
use core::iter::{repeat_with, FromIterator, FusedIterator};
1617
use core::mem::{self, replace, ManuallyDrop};
1718
use core::ops::{Index, IndexMut, Range, RangeBounds, Try};
1819
use core::ptr::{self, NonNull};
@@ -99,7 +100,7 @@ impl<'a, 'b, T> PairSlices<'a, 'b, T> {
99100
}
100101

101102
fn remainder(self) -> impl Iterator<Item = &'b [T]> {
102-
once(self.b0).chain(once(self.b1))
103+
array::IntoIter::new([self.b0, self.b1])
103104
}
104105
}
105106

alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#![cfg_attr(test, feature(new_uninit))]
7878
#![feature(allocator_api)]
7979
#![feature(array_chunks)]
80+
#![feature(array_value_iter)]
8081
#![feature(array_windows)]
8182
#![feature(allow_internal_unstable)]
8283
#![feature(arbitrary_self_types)]

0 commit comments

Comments
 (0)