Skip to content

Commit 199cebb

Browse files
committed
library: Rename IterRange* to Range*Iter
There is a weak convention in the ecosystem that `IterFoos` is an iterator yielding items of type `Foo` (e.g. bitflags` `IterNames`, `hashbrown` `IterBuckets`), while `FooIter` is an iterator over `Foo` from an `.iter()` or `.into_iter()` method (e.g. `memchr` `OneIter`, `regex` `SetMatchesIter`). Rename `IterRange`, `IterRangeInclusive`, and `IterRangeFrom` to `RangeIter`, `RangeInclusiveIter`, and `RangeInclusiveIter` to match this. Tracking issue: RUST-125687 (`new_range_api`)
1 parent 1d60f9e commit 199cebb

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

library/core/src/range.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod legacy;
2626

2727
use Bound::{Excluded, Included, Unbounded};
2828
#[doc(inline)]
29-
pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive};
29+
pub use iter::{RangeIter, RangeFromIter, RangeInclusiveIter};
3030

3131
#[doc(inline)]
3232
pub use crate::iter::Step;
@@ -89,7 +89,7 @@ impl<Idx: Step> Range<Idx> {
8989
/// ```
9090
#[unstable(feature = "new_range_api", issue = "125687")]
9191
#[inline]
92-
pub fn iter(&self) -> IterRange<Idx> {
92+
pub fn iter(&self) -> RangeIter<Idx> {
9393
self.clone().into_iter()
9494
}
9595
}
@@ -340,7 +340,7 @@ impl<Idx: Step> RangeInclusive<Idx> {
340340
/// ```
341341
#[unstable(feature = "new_range_api", issue = "125687")]
342342
#[inline]
343-
pub fn iter(&self) -> IterRangeInclusive<Idx> {
343+
pub fn iter(&self) -> RangeInclusiveIter<Idx> {
344344
self.clone().into_iter()
345345
}
346346
}
@@ -477,7 +477,7 @@ impl<Idx: Step> RangeFrom<Idx> {
477477
/// ```
478478
#[unstable(feature = "new_range_api", issue = "125687")]
479479
#[inline]
480-
pub fn iter(&self) -> IterRangeFrom<Idx> {
480+
pub fn iter(&self) -> RangeFromIter<Idx> {
481481
self.clone().into_iter()
482482
}
483483
}

library/core/src/range/iter.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use crate::{intrinsics, mem};
88
/// By-value [`Range`] iterator.
99
#[unstable(feature = "new_range_api", issue = "125687")]
1010
#[derive(Debug, Clone)]
11-
pub struct IterRange<A>(legacy::Range<A>);
11+
pub struct RangeIter<A>(legacy::Range<A>);
1212

13-
impl<A> IterRange<A> {
13+
impl<A> RangeIter<A> {
1414
/// Returns the remainder of the range being iterated over.
1515
pub fn remainder(self) -> Range<A> {
1616
Range { start: self.0.start, end: self.0.end }
@@ -23,11 +23,11 @@ macro_rules! unsafe_range_trusted_random_access_impl {
2323
($($t:ty)*) => ($(
2424
#[doc(hidden)]
2525
#[unstable(feature = "trusted_random_access", issue = "none")]
26-
unsafe impl TrustedRandomAccess for IterRange<$t> {}
26+
unsafe impl TrustedRandomAccess for RangeIter<$t> {}
2727

2828
#[doc(hidden)]
2929
#[unstable(feature = "trusted_random_access", issue = "none")]
30-
unsafe impl TrustedRandomAccessNoCoerce for IterRange<$t> {
30+
unsafe impl TrustedRandomAccessNoCoerce for RangeIter<$t> {
3131
const MAY_HAVE_SIDE_EFFECT: bool = false;
3232
}
3333
)*)
@@ -50,7 +50,7 @@ unsafe_range_trusted_random_access_impl! {
5050
}
5151

5252
#[unstable(feature = "new_range_api", issue = "125687")]
53-
impl<A: Step> Iterator for IterRange<A> {
53+
impl<A: Step> Iterator for RangeIter<A> {
5454
type Item = A;
5555

5656
#[inline]
@@ -118,7 +118,7 @@ impl<A: Step> Iterator for IterRange<A> {
118118
}
119119

120120
#[unstable(feature = "new_range_api", issue = "125687")]
121-
impl<A: Step> DoubleEndedIterator for IterRange<A> {
121+
impl<A: Step> DoubleEndedIterator for RangeIter<A> {
122122
#[inline]
123123
fn next_back(&mut self) -> Option<A> {
124124
self.0.next_back()
@@ -136,27 +136,27 @@ impl<A: Step> DoubleEndedIterator for IterRange<A> {
136136
}
137137

138138
#[unstable(feature = "trusted_len", issue = "37572")]
139-
unsafe impl<A: TrustedStep> TrustedLen for IterRange<A> {}
139+
unsafe impl<A: TrustedStep> TrustedLen for RangeIter<A> {}
140140

141141
#[unstable(feature = "new_range_api", issue = "125687")]
142-
impl<A: Step> FusedIterator for IterRange<A> {}
142+
impl<A: Step> FusedIterator for RangeIter<A> {}
143143

144144
#[unstable(feature = "new_range_api", issue = "125687")]
145145
impl<A: Step> IntoIterator for Range<A> {
146146
type Item = A;
147-
type IntoIter = IterRange<A>;
147+
type IntoIter = RangeIter<A>;
148148

149149
fn into_iter(self) -> Self::IntoIter {
150-
IterRange(self.into())
150+
RangeIter(self.into())
151151
}
152152
}
153153

154154
/// By-value [`RangeInclusive`] iterator.
155155
#[unstable(feature = "new_range_api", issue = "125687")]
156156
#[derive(Debug, Clone)]
157-
pub struct IterRangeInclusive<A>(legacy::RangeInclusive<A>);
157+
pub struct RangeInclusiveIter<A>(legacy::RangeInclusive<A>);
158158

159-
impl<A: Step> IterRangeInclusive<A> {
159+
impl<A: Step> RangeInclusiveIter<A> {
160160
/// Returns the remainder of the range being iterated over.
161161
///
162162
/// If the iterator is exhausted or empty, returns `None`.
@@ -170,7 +170,7 @@ impl<A: Step> IterRangeInclusive<A> {
170170
}
171171

172172
#[unstable(feature = "new_range_api", issue = "125687")]
173-
impl<A: Step> Iterator for IterRangeInclusive<A> {
173+
impl<A: Step> Iterator for RangeInclusiveIter<A> {
174174
type Item = A;
175175

176176
#[inline]
@@ -226,7 +226,7 @@ impl<A: Step> Iterator for IterRangeInclusive<A> {
226226
}
227227

228228
#[unstable(feature = "new_range_api", issue = "125687")]
229-
impl<A: Step> DoubleEndedIterator for IterRangeInclusive<A> {
229+
impl<A: Step> DoubleEndedIterator for RangeInclusiveIter<A> {
230230
#[inline]
231231
fn next_back(&mut self) -> Option<A> {
232232
self.0.next_back()
@@ -244,18 +244,18 @@ impl<A: Step> DoubleEndedIterator for IterRangeInclusive<A> {
244244
}
245245

246246
#[unstable(feature = "trusted_len", issue = "37572")]
247-
unsafe impl<A: TrustedStep> TrustedLen for IterRangeInclusive<A> {}
247+
unsafe impl<A: TrustedStep> TrustedLen for RangeInclusiveIter<A> {}
248248

249249
#[unstable(feature = "new_range_api", issue = "125687")]
250-
impl<A: Step> FusedIterator for IterRangeInclusive<A> {}
250+
impl<A: Step> FusedIterator for RangeInclusiveIter<A> {}
251251

252252
#[unstable(feature = "new_range_api", issue = "125687")]
253253
impl<A: Step> IntoIterator for RangeInclusive<A> {
254254
type Item = A;
255-
type IntoIter = IterRangeInclusive<A>;
255+
type IntoIter = RangeInclusiveIter<A>;
256256

257257
fn into_iter(self) -> Self::IntoIter {
258-
IterRangeInclusive(self.into())
258+
RangeInclusiveIter(self.into())
259259
}
260260
}
261261

@@ -270,14 +270,14 @@ impl<A: Step> IntoIterator for RangeInclusive<A> {
270270
macro_rules! range_exact_iter_impl {
271271
($($t:ty)*) => ($(
272272
#[unstable(feature = "new_range_api", issue = "125687")]
273-
impl ExactSizeIterator for IterRange<$t> { }
273+
impl ExactSizeIterator for RangeIter<$t> { }
274274
)*)
275275
}
276276

277277
macro_rules! range_incl_exact_iter_impl {
278278
($($t:ty)*) => ($(
279279
#[unstable(feature = "new_range_api", issue = "125687")]
280-
impl ExactSizeIterator for IterRangeInclusive<$t> { }
280+
impl ExactSizeIterator for RangeInclusiveIter<$t> { }
281281
)*)
282282
}
283283

@@ -294,14 +294,14 @@ range_incl_exact_iter_impl! {
294294
/// By-value [`RangeFrom`] iterator.
295295
#[unstable(feature = "new_range_api", issue = "125687")]
296296
#[derive(Debug, Clone)]
297-
pub struct IterRangeFrom<A> {
297+
pub struct RangeFromIter<A> {
298298
start: A,
299299
/// Whether the first element of the iterator has yielded.
300300
/// Only used when overflow checks are enabled.
301301
first: bool,
302302
}
303303

304-
impl<A: Step> IterRangeFrom<A> {
304+
impl<A: Step> RangeFromIter<A> {
305305
/// Returns the remainder of the range being iterated over.
306306
#[inline]
307307
#[rustc_inherit_overflow_checks]
@@ -317,7 +317,7 @@ impl<A: Step> IterRangeFrom<A> {
317317
}
318318

319319
#[unstable(feature = "new_range_api", issue = "125687")]
320-
impl<A: Step> Iterator for IterRangeFrom<A> {
320+
impl<A: Step> Iterator for RangeFromIter<A> {
321321
type Item = A;
322322

323323
#[inline]
@@ -366,17 +366,17 @@ impl<A: Step> Iterator for IterRangeFrom<A> {
366366
}
367367

368368
#[unstable(feature = "trusted_len", issue = "37572")]
369-
unsafe impl<A: TrustedStep> TrustedLen for IterRangeFrom<A> {}
369+
unsafe impl<A: TrustedStep> TrustedLen for RangeFromIter<A> {}
370370

371371
#[unstable(feature = "new_range_api", issue = "125687")]
372-
impl<A: Step> FusedIterator for IterRangeFrom<A> {}
372+
impl<A: Step> FusedIterator for RangeFromIter<A> {}
373373

374374
#[unstable(feature = "new_range_api", issue = "125687")]
375375
impl<A: Step> IntoIterator for RangeFrom<A> {
376376
type Item = A;
377-
type IntoIter = IterRangeFrom<A>;
377+
type IntoIter = RangeFromIter<A>;
378378

379379
fn into_iter(self) -> Self::IntoIter {
380-
IterRangeFrom { start: self.start, first: true }
380+
RangeFromIter { start: self.start, first: true }
381381
}
382382
}

tests/codegen-llvm/iterrangefrom-overflow-checks.rs renamed to tests/codegen-llvm/fromrangeiter-overflow-checks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
#![crate_type = "lib"]
1313
#![feature(new_range_api)]
14-
use std::range::{IterRangeFrom, RangeFrom};
14+
use std::range::{RangeFrom, RangeFromIter};
1515

1616
// CHECK-LABEL: @iterrangefrom_remainder(
1717
#[no_mangle]
18-
pub unsafe fn iterrangefrom_remainder(x: IterRangeFrom<i32>) -> RangeFrom<i32> {
18+
pub unsafe fn iterrangefrom_remainder(x: RangeFromIter<i32>) -> RangeFrom<i32> {
1919
// DEBUG: i32 noundef %x
2020
// NOCHECKS: i32 noundef returned %x
2121
// DEBUG: br i1
File renamed without changes.

tests/ui/new-range/enabled.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn main() {
1717
let c: core::range::RangeInclusive<u8> = 4..=5;
1818
let d: core::range::RangeToInclusive<u8> = ..=3;
1919

20-
let _: core::range::IterRangeFrom<u8> = a.into_iter();
21-
let _: core::range::IterRange<u8> = b.into_iter();
22-
let _: core::range::IterRangeInclusive<u8> = c.into_iter();
20+
let _: core::range::RangeFromIter<u8> = a.into_iter();
21+
let _: core::range::RangeIter<u8> = b.into_iter();
22+
let _: core::range::RangeInclusiveIter<u8> = c.into_iter();
2323
// RangeToInclusive has no Iterator implementation
2424
}

0 commit comments

Comments
 (0)