Skip to content

Commit 3060fe3

Browse files
committed
More consistent use of variable names for trait implementations
1 parent db9ab1a commit 3060fe3

11 files changed

Lines changed: 54 additions & 54 deletions

File tree

library/alloc/src/boxed/iter.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -93,103 +93,103 @@ impl<S: ?Sized + AsyncIterator + Unpin> AsyncIterator for Box<S> {
9393
}
9494
}
9595

96-
/// This implementation is required to make sure that the `Box<[I]>: IntoIterator`
96+
/// This implementation is required to make sure that the `Box<[T]>: IntoIterator`
9797
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
9898
#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
99-
impl<I, A: Allocator> !Iterator for Box<[I], A> {}
99+
impl<T, A: Allocator> !Iterator for Box<[T], A> {}
100100

101-
/// This implementation is required to make sure that the `&Box<[I]>: IntoIterator`
101+
/// This implementation is required to make sure that the `&Box<[T]>: IntoIterator`
102102
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
103103
#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
104-
impl<'a, I, A: Allocator> !Iterator for &'a Box<[I], A> {}
104+
impl<'a, T, A: Allocator> !Iterator for &'a Box<[T], A> {}
105105

106-
/// This implementation is required to make sure that the `&mut Box<[I]>: IntoIterator`
106+
/// This implementation is required to make sure that the `&mut Box<[T]>: IntoIterator`
107107
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
108108
#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
109-
impl<'a, I, A: Allocator> !Iterator for &'a mut Box<[I], A> {}
109+
impl<'a, T, A: Allocator> !Iterator for &'a mut Box<[T], A> {}
110110

111111
// Note: the `#[rustc_skip_during_method_dispatch(boxed_slice)]` on `trait IntoIterator`
112112
// hides this implementation from explicit `.into_iter()` calls on editions < 2024,
113113
// so those calls will still resolve to the slice implementation, by reference.
114114
#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
115-
impl<I, A: Allocator> IntoIterator for Box<[I], A> {
116-
type IntoIter = vec::IntoIter<I, A>;
117-
type Item = I;
118-
fn into_iter(self) -> vec::IntoIter<I, A> {
115+
impl<T, A: Allocator> IntoIterator for Box<[T], A> {
116+
type IntoIter = vec::IntoIter<T, A>;
117+
type Item = T;
118+
fn into_iter(self) -> vec::IntoIter<T, A> {
119119
self.into_vec().into_iter()
120120
}
121121
}
122122

123123
#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
124-
impl<'a, I, A: Allocator> IntoIterator for &'a Box<[I], A> {
125-
type IntoIter = slice::Iter<'a, I>;
126-
type Item = &'a I;
127-
fn into_iter(self) -> slice::Iter<'a, I> {
124+
impl<'a, T, A: Allocator> IntoIterator for &'a Box<[T], A> {
125+
type IntoIter = slice::Iter<'a, T>;
126+
type Item = &'a T;
127+
fn into_iter(self) -> slice::Iter<'a, T> {
128128
self.iter()
129129
}
130130
}
131131

132132
#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
133-
impl<'a, I, A: Allocator> IntoIterator for &'a mut Box<[I], A> {
134-
type IntoIter = slice::IterMut<'a, I>;
135-
type Item = &'a mut I;
136-
fn into_iter(self) -> slice::IterMut<'a, I> {
133+
impl<'a, T, A: Allocator> IntoIterator for &'a mut Box<[T], A> {
134+
type IntoIter = slice::IterMut<'a, T>;
135+
type Item = &'a mut T;
136+
fn into_iter(self) -> slice::IterMut<'a, T> {
137137
self.iter_mut()
138138
}
139139
}
140140

141141
#[cfg(not(no_global_oom_handling))]
142142
#[stable(feature = "boxed_slice_from_iter", since = "1.32.0")]
143-
impl<I> FromIterator<I> for Box<[I]> {
144-
fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self {
143+
impl<T> FromIterator<T> for Box<[T]> {
144+
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
145145
iter.into_iter().collect::<Vec<_>>().into_boxed_slice()
146146
}
147147
}
148148

149149
#[cfg(not(no_global_oom_handling))]
150150
#[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
151151
impl FromIterator<char> for Box<str> {
152-
fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self {
152+
fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self {
153153
String::from_iter(iter).into_boxed_str()
154154
}
155155
}
156156

157157
#[cfg(not(no_global_oom_handling))]
158158
#[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
159159
impl<'a> FromIterator<&'a char> for Box<str> {
160-
fn from_iter<T: IntoIterator<Item = &'a char>>(iter: T) -> Self {
160+
fn from_iter<I: IntoIterator<Item = &'a char>>(iter: I) -> Self {
161161
String::from_iter(iter).into_boxed_str()
162162
}
163163
}
164164

165165
#[cfg(not(no_global_oom_handling))]
166166
#[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
167167
impl<'a> FromIterator<&'a str> for Box<str> {
168-
fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
168+
fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> Self {
169169
String::from_iter(iter).into_boxed_str()
170170
}
171171
}
172172

173173
#[cfg(not(no_global_oom_handling))]
174174
#[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
175175
impl FromIterator<String> for Box<str> {
176-
fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
176+
fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> Self {
177177
String::from_iter(iter).into_boxed_str()
178178
}
179179
}
180180

181181
#[cfg(not(no_global_oom_handling))]
182182
#[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
183183
impl<A: Allocator> FromIterator<Box<str, A>> for Box<str> {
184-
fn from_iter<T: IntoIterator<Item = Box<str, A>>>(iter: T) -> Self {
184+
fn from_iter<I: IntoIterator<Item = Box<str, A>>>(iter: I) -> Self {
185185
String::from_iter(iter).into_boxed_str()
186186
}
187187
}
188188

189189
#[cfg(not(no_global_oom_handling))]
190190
#[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
191191
impl<'a> FromIterator<Cow<'a, str>> for Box<str> {
192-
fn from_iter<T: IntoIterator<Item = Cow<'a, str>>>(iter: T) -> Self {
192+
fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> Self {
193193
String::from_iter(iter).into_boxed_str()
194194
}
195195
}

library/alloc/src/bstr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,31 +281,31 @@ impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> {
281281
#[unstable(feature = "bstr", issue = "134915")]
282282
impl FromIterator<char> for ByteString {
283283
#[inline]
284-
fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self {
284+
fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self {
285285
ByteString(iter.into_iter().collect::<String>().into_bytes())
286286
}
287287
}
288288

289289
#[unstable(feature = "bstr", issue = "134915")]
290290
impl FromIterator<u8> for ByteString {
291291
#[inline]
292-
fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self {
292+
fn from_iter<I: IntoIterator<Item = u8>>(iter: I) -> Self {
293293
ByteString(iter.into_iter().collect())
294294
}
295295
}
296296

297297
#[unstable(feature = "bstr", issue = "134915")]
298298
impl<'a> FromIterator<&'a str> for ByteString {
299299
#[inline]
300-
fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
300+
fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> Self {
301301
ByteString(iter.into_iter().collect::<String>().into_bytes())
302302
}
303303
}
304304

305305
#[unstable(feature = "bstr", issue = "134915")]
306306
impl<'a> FromIterator<&'a [u8]> for ByteString {
307307
#[inline]
308-
fn from_iter<T: IntoIterator<Item = &'a [u8]>>(iter: T) -> Self {
308+
fn from_iter<I: IntoIterator<Item = &'a [u8]>>(iter: I) -> Self {
309309
let mut buf = Vec::new();
310310
for b in iter {
311311
buf.extend_from_slice(b);
@@ -317,7 +317,7 @@ impl<'a> FromIterator<&'a [u8]> for ByteString {
317317
#[unstable(feature = "bstr", issue = "134915")]
318318
impl<'a> FromIterator<&'a ByteStr> for ByteString {
319319
#[inline]
320-
fn from_iter<T: IntoIterator<Item = &'a ByteStr>>(iter: T) -> Self {
320+
fn from_iter<I: IntoIterator<Item = &'a ByteStr>>(iter: I) -> Self {
321321
let mut buf = Vec::new();
322322
for b in iter {
323323
buf.extend_from_slice(&b.0);
@@ -329,7 +329,7 @@ impl<'a> FromIterator<&'a ByteStr> for ByteString {
329329
#[unstable(feature = "bstr", issue = "134915")]
330330
impl FromIterator<ByteString> for ByteString {
331331
#[inline]
332-
fn from_iter<T: IntoIterator<Item = ByteString>>(iter: T) -> Self {
332+
fn from_iter<I: IntoIterator<Item = ByteString>>(iter: I) -> Self {
333333
let mut buf = Vec::new();
334334
for mut b in iter {
335335
buf.append(&mut b.0);

library/alloc/src/collections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
25412541
///
25422542
/// If the iterator produces any pairs with equal keys,
25432543
/// all but one of the corresponding values will be dropped.
2544-
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> BTreeMap<K, V> {
2544+
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> BTreeMap<K, V> {
25452545
let mut inputs: Vec<_> = iter.into_iter().collect();
25462546

25472547
if inputs.is_empty() {
@@ -2557,7 +2557,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
25572557
#[stable(feature = "rust1", since = "1.0.0")]
25582558
impl<K: Ord, V, A: Allocator + Clone> Extend<(K, V)> for BTreeMap<K, V, A> {
25592559
#[inline]
2560-
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
2560+
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I) {
25612561
iter.into_iter().for_each(move |(k, v)| {
25622562
self.insert(k, v);
25632563
});

library/alloc/src/string.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,7 @@ impl<'a> FromIterator<Cow<'a, str>> for String {
24802480
#[cfg(not(no_global_oom_handling))]
24812481
#[unstable(feature = "ascii_char", issue = "110998")]
24822482
impl FromIterator<core::ascii::Char> for String {
2483-
fn from_iter<T: IntoIterator<Item = core::ascii::Char>>(iter: T) -> Self {
2483+
fn from_iter<I: IntoIterator<Item = core::ascii::Char>>(iter: I) -> Self {
24842484
let buf = iter.into_iter().map(core::ascii::Char::to_u8).collect();
24852485
// SAFETY: `buf` is guaranteed to be valid UTF-8 because the `core::ascii::Char` type
24862486
// only contains ASCII values (0x00-0x7F), which are valid UTF-8.
@@ -2491,7 +2491,7 @@ impl FromIterator<core::ascii::Char> for String {
24912491
#[cfg(not(no_global_oom_handling))]
24922492
#[unstable(feature = "ascii_char", issue = "110998")]
24932493
impl<'a> FromIterator<&'a core::ascii::Char> for String {
2494-
fn from_iter<T: IntoIterator<Item = &'a core::ascii::Char>>(iter: T) -> Self {
2494+
fn from_iter<I: IntoIterator<Item = &'a core::ascii::Char>>(iter: I) -> Self {
24952495
let buf = iter.into_iter().copied().map(core::ascii::Char::to_u8).collect();
24962496
// SAFETY: `buf` is guaranteed to be valid UTF-8 because the `core::ascii::Char` type
24972497
// only contains ASCII values (0x00-0x7F), which are valid UTF-8.
@@ -3332,7 +3332,7 @@ impl<'a> FromIterator<String> for Cow<'a, str> {
33323332
#[cfg(not(no_global_oom_handling))]
33333333
#[unstable(feature = "ascii_char", issue = "110998")]
33343334
impl<'a> FromIterator<core::ascii::Char> for Cow<'a, str> {
3335-
fn from_iter<T: IntoIterator<Item = core::ascii::Char>>(it: T) -> Self {
3335+
fn from_iter<I: IntoIterator<Item = core::ascii::Char>>(it: I) -> Self {
33363336
Cow::Owned(FromIterator::from_iter(it))
33373337
}
33383338
}

library/alloc/src/wtf8/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl Wtf8Buf {
423423
/// This replaces surrogate code point pairs with supplementary code points,
424424
/// like concatenating ill-formed UTF-16 strings effectively would.
425425
impl FromIterator<CodePoint> for Wtf8Buf {
426-
fn from_iter<T: IntoIterator<Item = CodePoint>>(iter: T) -> Wtf8Buf {
426+
fn from_iter<I: IntoIterator<Item = CodePoint>>(iter: I) -> Wtf8Buf {
427427
let mut string = Wtf8Buf::new();
428428
string.extend(iter);
429429
string
@@ -435,7 +435,7 @@ impl FromIterator<CodePoint> for Wtf8Buf {
435435
/// This replaces surrogate code point pairs with supplementary code points,
436436
/// like concatenating ill-formed UTF-16 strings effectively would.
437437
impl Extend<CodePoint> for Wtf8Buf {
438-
fn extend<T: IntoIterator<Item = CodePoint>>(&mut self, iter: T) {
438+
fn extend<I: IntoIterator<Item = CodePoint>>(&mut self, iter: I) {
439439
let iterator = iter.into_iter();
440440
let (low, _high) = iterator.size_hint();
441441
// Lower bound of one byte per code point (ASCII only)

library/core/src/iter/traits/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ const impl<I: [const] Iterator> IntoIterator for I {
371371
/// // This is a bit simpler with the concrete type signature: we can call
372372
/// // extend on anything which can be turned into an Iterator which gives
373373
/// // us i32s. Because we need i32s to put into MyCollection.
374-
/// fn extend<T: IntoIterator<Item=i32>>(&mut self, iter: T) {
374+
/// fn extend<I: IntoIterator<Item=i32>>(&mut self, iter: I) {
375375
///
376376
/// // The implementation is very straightforward: loop through the
377377
/// // iterator, and add() each element to ourselves.
@@ -452,7 +452,7 @@ pub trait Extend<T> {
452452

453453
#[stable(feature = "extend_for_unit", since = "1.28.0")]
454454
impl Extend<()> for () {
455-
fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T) {
455+
fn extend<I: IntoIterator<Item = ()>>(&mut self, iter: I) {
456456
iter.into_iter().for_each(drop)
457457
}
458458
fn extend_one(&mut self, _item: ()) {}

library/core/src/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@
465465
//! [`Option`] of a collection of each contained value of the original
466466
//! [`Option`] values, or [`None`] if any of the elements was [`None`].
467467
//!
468-
//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CA%3E%3E-for-Option%3CV%3E
468+
//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CT%3E%3E-for-Option%3CV%3E
469469
//!
470470
//! ```
471471
//! let v = [Some(2), Some(4), None, Some(8)];
@@ -2786,7 +2786,7 @@ unsafe impl<A: TrustedLen> TrustedLen for OptionFlatten<A> {}
27862786
/////////////////////////////////////////////////////////////////////////////
27872787

27882788
#[stable(feature = "rust1", since = "1.0.0")]
2789-
impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
2789+
impl<T, V: FromIterator<T>> FromIterator<Option<T>> for Option<V> {
27902790
/// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],
27912791
/// no further elements are taken, and the [`None`][Option::None] is
27922792
/// returned. Should no [`None`][Option::None] occur, a container of type
@@ -2848,7 +2848,7 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
28482848
/// Since the third element caused an underflow, no further elements were taken,
28492849
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
28502850
#[inline]
2851-
fn from_iter<I: IntoIterator<Item = Option<A>>>(iter: I) -> Option<V> {
2851+
fn from_iter<I: IntoIterator<Item = Option<T>>>(iter: I) -> Option<V> {
28522852
iter::try_process(iter.into_iter(), |i| i.collect())
28532853
}
28542854
}

library/core/src/result.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@
511511
//! [`Result`] of a collection of each contained value of the original
512512
//! [`Result`] values, or [`Err`] if any of the elements was [`Err`].
513513
//!
514-
//! [impl-FromIterator]: Result#impl-FromIterator%3CResult%3CA,+E%3E%3E-for-Result%3CV,+E%3E
514+
//! [impl-FromIterator]: Result#impl-FromIterator%3CResult%3CT,+E%3E%3E-for-Result%3CV,+E%3E
515515
//!
516516
//! ```
517517
//! let v = [Ok(2), Ok(4), Err("err!"), Ok(8)];
@@ -2112,7 +2112,7 @@ unsafe impl<A> TrustedLen for IntoIter<A> {}
21122112
/////////////////////////////////////////////////////////////////////////////
21132113

21142114
#[stable(feature = "rust1", since = "1.0.0")]
2115-
impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
2115+
impl<T, E, V: FromIterator<T>> FromIterator<Result<T, E>> for Result<V, E> {
21162116
/// Takes each element in the `Iterator`: if it is an `Err`, no further
21172117
/// elements are taken, and the `Err` is returned. Should no `Err` occur, a
21182118
/// container with the values of each `Result` is returned.
@@ -2156,7 +2156,7 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
21562156
/// Since the third element caused an underflow, no further elements were taken,
21572157
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
21582158
#[inline]
2159-
fn from_iter<I: IntoIterator<Item = Result<A, E>>>(iter: I) -> Result<V, E> {
2159+
fn from_iter<I: IntoIterator<Item = Result<T, E>>>(iter: I) -> Result<V, E> {
21602160
iter::try_process(iter.into_iter(), |i| i.collect())
21612161
}
21622162
}

library/proc_macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ macro_rules! extend_items {
516516
$(
517517
#[stable(feature = "token_stream_extend_ts_items", since = "1.92.0")]
518518
impl Extend<$item> for TokenStream {
519-
fn extend<T: IntoIterator<Item = $item>>(&mut self, iter: T) {
519+
fn extend<I: IntoIterator<Item = $item>>(&mut self, iter: I) {
520520
self.extend(iter.into_iter().map(TokenTree::$item));
521521
}
522522
}

library/std/src/collections/hash/map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,7 @@ where
30103010
///
30113011
/// If the iterator produces any pairs with equal keys,
30123012
/// all but one of the corresponding values will be dropped.
3013-
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> HashMap<K, V, S> {
3013+
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> HashMap<K, V, S> {
30143014
let mut map = HashMap::with_hasher(Default::default());
30153015
map.extend(iter);
30163016
map
@@ -3027,7 +3027,7 @@ where
30273027
A: Allocator,
30283028
{
30293029
#[inline]
3030-
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
3030+
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I) {
30313031
self.base.extend(iter)
30323032
}
30333033

@@ -3051,7 +3051,7 @@ where
30513051
A: Allocator,
30523052
{
30533053
#[inline]
3054-
fn extend<T: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: T) {
3054+
fn extend<I: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: I) {
30553055
self.base.extend(iter)
30563056
}
30573057

0 commit comments

Comments
 (0)