core/iter/traits/collect.rs
1#[cfg(not(feature = "ferrocene_subset"))]
2use super::TrustedLen;
3
4/// Conversion from an [`Iterator`].
5///
6/// By implementing `FromIterator` for a type, you define how it will be
7/// created from an iterator. This is common for types which describe a
8/// collection of some kind.
9///
10/// If you want to create a collection from the contents of an iterator, the
11/// [`Iterator::collect()`] method is preferred. However, when you need to
12/// specify the container type, [`FromIterator::from_iter()`] can be more
13/// readable than using a turbofish (e.g. `::<Vec<_>>()`). See the
14/// [`Iterator::collect()`] documentation for more examples of its use.
15///
16/// See also: [`IntoIterator`].
17///
18/// # Examples
19///
20/// Basic usage:
21///
22/// ```
23/// let five_fives = std::iter::repeat(5).take(5);
24///
25/// let v = Vec::from_iter(five_fives);
26///
27/// assert_eq!(v, vec![5, 5, 5, 5, 5]);
28/// ```
29///
30/// Using [`Iterator::collect()`] to implicitly use `FromIterator`:
31///
32/// ```
33/// let five_fives = std::iter::repeat(5).take(5);
34///
35/// let v: Vec<i32> = five_fives.collect();
36///
37/// assert_eq!(v, vec![5, 5, 5, 5, 5]);
38/// ```
39///
40/// Using [`FromIterator::from_iter()`] as a more readable alternative to
41/// [`Iterator::collect()`]:
42///
43/// ```
44/// use std::collections::VecDeque;
45/// let first = (0..10).collect::<VecDeque<i32>>();
46/// let second = VecDeque::from_iter(0..10);
47///
48/// assert_eq!(first, second);
49/// ```
50///
51/// Implementing `FromIterator` for your type:
52///
53/// ```
54/// // A sample collection, that's just a wrapper over Vec<T>
55/// #[derive(Debug)]
56/// struct MyCollection(Vec<i32>);
57///
58/// // Let's give it some methods so we can create one and add things
59/// // to it.
60/// impl MyCollection {
61/// fn new() -> MyCollection {
62/// MyCollection(Vec::new())
63/// }
64///
65/// fn add(&mut self, elem: i32) {
66/// self.0.push(elem);
67/// }
68/// }
69///
70/// // and we'll implement FromIterator
71/// impl FromIterator<i32> for MyCollection {
72/// fn from_iter<I: IntoIterator<Item=i32>>(iter: I) -> Self {
73/// let mut c = MyCollection::new();
74///
75/// for i in iter {
76/// c.add(i);
77/// }
78///
79/// c
80/// }
81/// }
82///
83/// // Now we can make a new iterator...
84/// let iter = (0..5).into_iter();
85///
86/// // ... and make a MyCollection out of it
87/// let c = MyCollection::from_iter(iter);
88///
89/// assert_eq!(c.0, vec![0, 1, 2, 3, 4]);
90///
91/// // collect works too!
92///
93/// let iter = (0..5).into_iter();
94/// let c: MyCollection = iter.collect();
95///
96/// assert_eq!(c.0, vec![0, 1, 2, 3, 4]);
97/// ```
98#[stable(feature = "rust1", since = "1.0.0")]
99#[rustc_on_unimplemented(
100 on(
101 Self = "&[{A}]",
102 message = "a slice of type `{Self}` cannot be built since we need to store the elements somewhere",
103 label = "try explicitly collecting into a `Vec<{A}>`",
104 ),
105 on(
106 all(A = "{integer}", any(Self = "&[{integral}]",)),
107 message = "a slice of type `{Self}` cannot be built since we need to store the elements somewhere",
108 label = "try explicitly collecting into a `Vec<{A}>`",
109 ),
110 on(
111 Self = "[{A}]",
112 message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
113 label = "try explicitly collecting into a `Vec<{A}>`",
114 ),
115 on(
116 all(A = "{integer}", any(Self = "[{integral}]",)),
117 message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
118 label = "try explicitly collecting into a `Vec<{A}>`",
119 ),
120 on(
121 Self = "[{A}; _]",
122 message = "an array of type `{Self}` cannot be built directly from an iterator",
123 label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
124 ),
125 on(
126 all(A = "{integer}", any(Self = "[{integral}; _]",)),
127 message = "an array of type `{Self}` cannot be built directly from an iterator",
128 label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
129 ),
130 message = "a value of type `{Self}` cannot be built from an iterator \
131 over elements of type `{A}`",
132 label = "value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`"
133)]
134#[rustc_diagnostic_item = "FromIterator"]
135pub trait FromIterator<A>: Sized {
136 /// Creates a value from an iterator.
137 ///
138 /// See the [module-level documentation] for more.
139 ///
140 /// [module-level documentation]: crate::iter
141 ///
142 /// # Examples
143 ///
144 /// ```
145 /// let five_fives = std::iter::repeat(5).take(5);
146 ///
147 /// let v = Vec::from_iter(five_fives);
148 ///
149 /// assert_eq!(v, vec![5, 5, 5, 5, 5]);
150 /// ```
151 #[stable(feature = "rust1", since = "1.0.0")]
152 #[rustc_diagnostic_item = "from_iter_fn"]
153 fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
154}
155
156/// Conversion into an [`Iterator`].
157///
158/// By implementing `IntoIterator` for a type, you define how it will be
159/// converted to an iterator. This is common for types which describe a
160/// collection of some kind.
161///
162/// One benefit of implementing `IntoIterator` is that your type will [work
163/// with Rust's `for` loop syntax](crate::iter#for-loops-and-intoiterator).
164///
165/// See also: [`FromIterator`].
166///
167/// # Examples
168///
169/// Basic usage:
170///
171/// ```
172/// let v = [1, 2, 3];
173/// let mut iter = v.into_iter();
174///
175/// assert_eq!(Some(1), iter.next());
176/// assert_eq!(Some(2), iter.next());
177/// assert_eq!(Some(3), iter.next());
178/// assert_eq!(None, iter.next());
179/// ```
180/// Implementing `IntoIterator` for your type:
181///
182/// ```
183/// // A sample collection, that's just a wrapper over Vec<T>
184/// #[derive(Debug)]
185/// struct MyCollection(Vec<i32>);
186///
187/// // Let's give it some methods so we can create one and add things
188/// // to it.
189/// impl MyCollection {
190/// fn new() -> MyCollection {
191/// MyCollection(Vec::new())
192/// }
193///
194/// fn add(&mut self, elem: i32) {
195/// self.0.push(elem);
196/// }
197/// }
198///
199/// // and we'll implement IntoIterator
200/// impl IntoIterator for MyCollection {
201/// type Item = i32;
202/// type IntoIter = std::vec::IntoIter<Self::Item>;
203///
204/// fn into_iter(self) -> Self::IntoIter {
205/// self.0.into_iter()
206/// }
207/// }
208///
209/// // Now we can make a new collection...
210/// let mut c = MyCollection::new();
211///
212/// // ... add some stuff to it ...
213/// c.add(0);
214/// c.add(1);
215/// c.add(2);
216///
217/// // ... and then turn it into an Iterator:
218/// for (i, n) in c.into_iter().enumerate() {
219/// assert_eq!(i as i32, n);
220/// }
221/// ```
222///
223/// It is common to use `IntoIterator` as a trait bound. This allows
224/// the input collection type to change, so long as it is still an
225/// iterator. Additional bounds can be specified by restricting on
226/// `Item`:
227///
228/// ```rust
229/// fn collect_as_strings<T>(collection: T) -> Vec<String>
230/// where
231/// T: IntoIterator,
232/// T::Item: std::fmt::Debug,
233/// {
234/// collection
235/// .into_iter()
236/// .map(|item| format!("{item:?}"))
237/// .collect()
238/// }
239/// ```
240#[rustc_diagnostic_item = "IntoIterator"]
241#[rustc_on_unimplemented(
242 on(
243 Self = "core::ops::range::RangeTo<Idx>",
244 label = "if you meant to iterate until a value, add a starting value",
245 note = "`..end` is a `RangeTo`, which cannot be iterated on; you might have meant to have a \
246 bounded `Range`: `0..end`"
247 ),
248 on(
249 Self = "core::ops::range::RangeToInclusive<Idx>",
250 label = "if you meant to iterate until a value (including it), add a starting value",
251 note = "`..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant \
252 to have a bounded `RangeInclusive`: `0..=end`"
253 ),
254 on(
255 Self = "[]",
256 label = "`{Self}` is not an iterator; try calling `.into_iter()` or `.iter()`"
257 ),
258 on(Self = "&[]", label = "`{Self}` is not an iterator; try calling `.iter()`"),
259 on(
260 Self = "alloc::vec::Vec<T, A>",
261 label = "`{Self}` is not an iterator; try calling `.into_iter()` or `.iter()`"
262 ),
263 on(Self = "&str", label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"),
264 on(
265 Self = "alloc::string::String",
266 label = "`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
267 ),
268 on(
269 Self = "{integral}",
270 note = "if you want to iterate between `start` until a value `end`, use the exclusive range \
271 syntax `start..end` or the inclusive range syntax `start..=end`"
272 ),
273 on(
274 Self = "{float}",
275 note = "if you want to iterate between `start` until a value `end`, use the exclusive range \
276 syntax `start..end` or the inclusive range syntax `start..=end`"
277 ),
278 label = "`{Self}` is not an iterator",
279 message = "`{Self}` is not an iterator"
280)]
281#[rustc_skip_during_method_dispatch(array, boxed_slice)]
282#[stable(feature = "rust1", since = "1.0.0")]
283pub trait IntoIterator {
284 /// The type of the elements being iterated over.
285 #[rustc_diagnostic_item = "IntoIteratorItem"]
286 #[stable(feature = "rust1", since = "1.0.0")]
287 type Item;
288
289 /// Which kind of iterator are we turning this into?
290 #[stable(feature = "rust1", since = "1.0.0")]
291 type IntoIter: Iterator<Item = Self::Item>;
292
293 /// Creates an iterator from a value.
294 ///
295 /// See the [module-level documentation] for more.
296 ///
297 /// [module-level documentation]: crate::iter
298 ///
299 /// # Examples
300 ///
301 /// ```
302 /// let v = [1, 2, 3];
303 /// let mut iter = v.into_iter();
304 ///
305 /// assert_eq!(Some(1), iter.next());
306 /// assert_eq!(Some(2), iter.next());
307 /// assert_eq!(Some(3), iter.next());
308 /// assert_eq!(None, iter.next());
309 /// ```
310 #[lang = "into_iter"]
311 #[stable(feature = "rust1", since = "1.0.0")]
312 fn into_iter(self) -> Self::IntoIter;
313}
314
315#[stable(feature = "rust1", since = "1.0.0")]
316impl<I: Iterator> IntoIterator for I {
317 type Item = I::Item;
318 type IntoIter = I;
319
320 #[inline]
321 fn into_iter(self) -> I {
322 self
323 }
324}
325
326/// Extend a collection with the contents of an iterator.
327///
328/// Iterators produce a series of values, and collections can also be thought
329/// of as a series of values. The `Extend` trait bridges this gap, allowing you
330/// to extend a collection by including the contents of that iterator. When
331/// extending a collection with an already existing key, that entry is updated
332/// or, in the case of collections that permit multiple entries with equal
333/// keys, that entry is inserted.
334///
335/// # Examples
336///
337/// Basic usage:
338///
339/// ```
340/// // You can extend a String with some chars:
341/// let mut message = String::from("The first three letters are: ");
342///
343/// message.extend(&['a', 'b', 'c']);
344///
345/// assert_eq!("abc", &message[29..32]);
346/// ```
347///
348/// Implementing `Extend`:
349///
350/// ```
351/// // A sample collection, that's just a wrapper over Vec<T>
352/// #[derive(Debug)]
353/// struct MyCollection(Vec<i32>);
354///
355/// // Let's give it some methods so we can create one and add things
356/// // to it.
357/// impl MyCollection {
358/// fn new() -> MyCollection {
359/// MyCollection(Vec::new())
360/// }
361///
362/// fn add(&mut self, elem: i32) {
363/// self.0.push(elem);
364/// }
365/// }
366///
367/// // since MyCollection has a list of i32s, we implement Extend for i32
368/// impl Extend<i32> for MyCollection {
369///
370/// // This is a bit simpler with the concrete type signature: we can call
371/// // extend on anything which can be turned into an Iterator which gives
372/// // us i32s. Because we need i32s to put into MyCollection.
373/// fn extend<T: IntoIterator<Item=i32>>(&mut self, iter: T) {
374///
375/// // The implementation is very straightforward: loop through the
376/// // iterator, and add() each element to ourselves.
377/// for elem in iter {
378/// self.add(elem);
379/// }
380/// }
381/// }
382///
383/// let mut c = MyCollection::new();
384///
385/// c.add(5);
386/// c.add(6);
387/// c.add(7);
388///
389/// // let's extend our collection with three more numbers
390/// c.extend(vec![1, 2, 3]);
391///
392/// // we've added these elements onto the end
393/// assert_eq!("MyCollection([5, 6, 7, 1, 2, 3])", format!("{c:?}"));
394/// ```
395#[stable(feature = "rust1", since = "1.0.0")]
396pub trait Extend<A> {
397 /// Extends a collection with the contents of an iterator.
398 ///
399 /// As this is the only required method for this trait, the [trait-level] docs
400 /// contain more details.
401 ///
402 /// [trait-level]: Extend
403 ///
404 /// # Examples
405 ///
406 /// ```
407 /// // You can extend a String with some chars:
408 /// let mut message = String::from("abc");
409 ///
410 /// message.extend(['d', 'e', 'f'].iter());
411 ///
412 /// assert_eq!("abcdef", &message);
413 /// ```
414 #[stable(feature = "rust1", since = "1.0.0")]
415 fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T);
416
417 /// Extends a collection with exactly one element.
418 #[unstable(feature = "extend_one", issue = "72631")]
419 fn extend_one(&mut self, item: A) {
420 self.extend(Some(item));
421 }
422
423 /// Reserves capacity in a collection for the given number of additional elements.
424 ///
425 /// The default implementation does nothing.
426 #[unstable(feature = "extend_one", issue = "72631")]
427 fn extend_reserve(&mut self, additional: usize) {
428 let _ = additional;
429 }
430
431 /// Extends a collection with one element, without checking there is enough capacity for it.
432 ///
433 /// # Safety
434 ///
435 /// **For callers:** This must only be called when we know the collection has enough capacity
436 /// to contain the new item, for example because we previously called `extend_reserve`.
437 ///
438 /// **For implementors:** For a collection to unsafely rely on this method's safety precondition (that is,
439 /// invoke UB if they are violated), it must implement `extend_reserve` correctly. In other words,
440 /// callers may assume that if they `extend_reserve`ed enough space they can call this method.
441 // This method is for internal usage only. It is only on the trait because of specialization's limitations.
442 #[unstable(feature = "extend_one_unchecked", issue = "none")]
443 #[doc(hidden)]
444 unsafe fn extend_one_unchecked(&mut self, item: A)
445 where
446 Self: Sized,
447 {
448 self.extend_one(item);
449 }
450}
451
452#[stable(feature = "extend_for_unit", since = "1.28.0")]
453#[cfg(not(feature = "ferrocene_subset"))]
454impl Extend<()> for () {
455 fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T) {
456 iter.into_iter().for_each(drop)
457 }
458 fn extend_one(&mut self, _item: ()) {}
459}
460
461/// This trait is implemented for tuples up to twelve items long. The `impl`s for
462/// 1- and 3- through 12-ary tuples were stabilized after 2-tuples, in 1.85.0.
463#[doc(fake_variadic)] // the other implementations are below.
464#[stable(feature = "extend_for_tuple", since = "1.56.0")]
465#[cfg(not(feature = "ferrocene_subset"))]
466impl<T, ExtendT> Extend<(T,)> for (ExtendT,)
467where
468 ExtendT: Extend<T>,
469{
470 /// Allows to `extend` a tuple of collections that also implement `Extend`.
471 ///
472 /// See also: [`Iterator::unzip`]
473 ///
474 /// # Examples
475 /// ```
476 /// // Example given for a 2-tuple, but 1- through 12-tuples are supported
477 /// let mut tuple = (vec![0], vec![1]);
478 /// tuple.extend([(2, 3), (4, 5), (6, 7)]);
479 /// assert_eq!(tuple.0, [0, 2, 4, 6]);
480 /// assert_eq!(tuple.1, [1, 3, 5, 7]);
481 ///
482 /// // also allows for arbitrarily nested tuples as elements
483 /// let mut nested_tuple = (vec![1], (vec![2], vec![3]));
484 /// nested_tuple.extend([(4, (5, 6)), (7, (8, 9))]);
485 ///
486 /// let (a, (b, c)) = nested_tuple;
487 /// assert_eq!(a, [1, 4, 7]);
488 /// assert_eq!(b, [2, 5, 8]);
489 /// assert_eq!(c, [3, 6, 9]);
490 /// ```
491 fn extend<I: IntoIterator<Item = (T,)>>(&mut self, iter: I) {
492 self.0.extend(iter.into_iter().map(|t| t.0));
493 }
494
495 fn extend_one(&mut self, item: (T,)) {
496 self.0.extend_one(item.0)
497 }
498
499 fn extend_reserve(&mut self, additional: usize) {
500 self.0.extend_reserve(additional)
501 }
502
503 unsafe fn extend_one_unchecked(&mut self, item: (T,)) {
504 // SAFETY: the caller guarantees all preconditions.
505 unsafe { self.0.extend_one_unchecked(item.0) }
506 }
507}
508
509/// This implementation turns an iterator of tuples into a tuple of types which implement
510/// [`Default`] and [`Extend`].
511///
512/// This is similar to [`Iterator::unzip`], but is also composable with other [`FromIterator`]
513/// implementations:
514///
515/// ```rust
516/// # fn main() -> Result<(), core::num::ParseIntError> {
517/// let string = "1,2,123,4";
518///
519/// // Example given for a 2-tuple, but 1- through 12-tuples are supported
520/// let (numbers, lengths): (Vec<_>, Vec<_>) = string
521/// .split(',')
522/// .map(|s| s.parse().map(|n: u32| (n, s.len())))
523/// .collect::<Result<_, _>>()?;
524///
525/// assert_eq!(numbers, [1, 2, 123, 4]);
526/// assert_eq!(lengths, [1, 1, 3, 1]);
527/// # Ok(()) }
528/// ```
529#[doc(fake_variadic)] // the other implementations are below.
530#[stable(feature = "from_iterator_for_tuple", since = "1.79.0")]
531#[cfg(not(feature = "ferrocene_subset"))]
532impl<T, ExtendT> FromIterator<(T,)> for (ExtendT,)
533where
534 ExtendT: Default + Extend<T>,
535{
536 fn from_iter<Iter: IntoIterator<Item = (T,)>>(iter: Iter) -> Self {
537 let mut res = ExtendT::default();
538 res.extend(iter.into_iter().map(|t| t.0));
539 (res,)
540 }
541}
542
543/// An implementation of [`extend`](Extend::extend) that calls `extend_one` or
544/// `extend_one_unchecked` for each element of the iterator.
545#[cfg(not(feature = "ferrocene_subset"))]
546fn default_extend<ExtendT, I, T>(collection: &mut ExtendT, iter: I)
547where
548 ExtendT: Extend<T>,
549 I: IntoIterator<Item = T>,
550{
551 // Specialize on `TrustedLen` and call `extend_one_unchecked` where
552 // applicable.
553 trait SpecExtend<I> {
554 fn extend(&mut self, iter: I);
555 }
556
557 // Extracting these to separate functions avoid monomorphising the closures
558 // for every iterator type.
559 fn extender<ExtendT, T>(collection: &mut ExtendT) -> impl FnMut(T) + use<'_, ExtendT, T>
560 where
561 ExtendT: Extend<T>,
562 {
563 move |item| collection.extend_one(item)
564 }
565
566 unsafe fn unchecked_extender<ExtendT, T>(
567 collection: &mut ExtendT,
568 ) -> impl FnMut(T) + use<'_, ExtendT, T>
569 where
570 ExtendT: Extend<T>,
571 {
572 // SAFETY: we make sure that there is enough space at the callsite of
573 // this function.
574 move |item| unsafe { collection.extend_one_unchecked(item) }
575 }
576
577 impl<ExtendT, I, T> SpecExtend<I> for ExtendT
578 where
579 ExtendT: Extend<T>,
580 I: Iterator<Item = T>,
581 {
582 default fn extend(&mut self, iter: I) {
583 let (lower_bound, _) = iter.size_hint();
584 if lower_bound > 0 {
585 self.extend_reserve(lower_bound);
586 }
587
588 iter.for_each(extender(self))
589 }
590 }
591
592 impl<ExtendT, I, T> SpecExtend<I> for ExtendT
593 where
594 ExtendT: Extend<T>,
595 I: TrustedLen<Item = T>,
596 {
597 fn extend(&mut self, iter: I) {
598 let (lower_bound, upper_bound) = iter.size_hint();
599 if lower_bound > 0 {
600 self.extend_reserve(lower_bound);
601 }
602
603 if upper_bound.is_none() {
604 // We cannot reserve more than `usize::MAX` items, and this is likely to go out of memory anyway.
605 iter.for_each(extender(self))
606 } else {
607 // SAFETY: We reserve enough space for the `size_hint`, and the iterator is
608 // `TrustedLen` so its `size_hint` is exact.
609 iter.for_each(unsafe { unchecked_extender(self) })
610 }
611 }
612 }
613
614 SpecExtend::extend(collection, iter.into_iter());
615}
616
617// Implements `Extend` and `FromIterator` for tuples with length larger than one.
618macro_rules! impl_extend_tuple {
619 ($(($ty:tt, $extend_ty:tt, $index:tt)),+) => {
620 #[doc(hidden)]
621 #[stable(feature = "extend_for_tuple", since = "1.56.0")]
622 #[cfg(not(feature = "ferrocene_subset"))]
623 impl<$($ty,)+ $($extend_ty,)+> Extend<($($ty,)+)> for ($($extend_ty,)+)
624 where
625 $($extend_ty: Extend<$ty>,)+
626 {
627 fn extend<T: IntoIterator<Item = ($($ty,)+)>>(&mut self, iter: T) {
628 default_extend(self, iter)
629 }
630
631 fn extend_one(&mut self, item: ($($ty,)+)) {
632 $(self.$index.extend_one(item.$index);)+
633 }
634
635 fn extend_reserve(&mut self, additional: usize) {
636 $(self.$index.extend_reserve(additional);)+
637 }
638
639 unsafe fn extend_one_unchecked(&mut self, item: ($($ty,)+)) {
640 // SAFETY: Those are our safety preconditions, and we correctly forward `extend_reserve`.
641 unsafe {
642 $(self.$index.extend_one_unchecked(item.$index);)+
643 }
644 }
645 }
646
647 #[doc(hidden)]
648 #[stable(feature = "from_iterator_for_tuple", since = "1.79.0")]
649 #[cfg(not(feature = "ferrocene_subset"))]
650 impl<$($ty,)+ $($extend_ty,)+> FromIterator<($($ty,)+)> for ($($extend_ty,)+)
651 where
652 $($extend_ty: Default + Extend<$ty>,)+
653 {
654 fn from_iter<Iter: IntoIterator<Item = ($($ty,)+)>>(iter: Iter) -> Self {
655 let mut res = Self::default();
656 res.extend(iter);
657 res
658 }
659 }
660 };
661}
662
663impl_extend_tuple!((A, ExA, 0), (B, ExB, 1));
664impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2));
665impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2), (D, ExD, 3));
666impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2), (D, ExD, 3), (E, ExE, 4));
667impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2), (D, ExD, 3), (E, ExE, 4), (F, ExF, 5));
668impl_extend_tuple!(
669 (A, ExA, 0),
670 (B, ExB, 1),
671 (C, ExC, 2),
672 (D, ExD, 3),
673 (E, ExE, 4),
674 (F, ExF, 5),
675 (G, ExG, 6)
676);
677impl_extend_tuple!(
678 (A, ExA, 0),
679 (B, ExB, 1),
680 (C, ExC, 2),
681 (D, ExD, 3),
682 (E, ExE, 4),
683 (F, ExF, 5),
684 (G, ExG, 6),
685 (H, ExH, 7)
686);
687impl_extend_tuple!(
688 (A, ExA, 0),
689 (B, ExB, 1),
690 (C, ExC, 2),
691 (D, ExD, 3),
692 (E, ExE, 4),
693 (F, ExF, 5),
694 (G, ExG, 6),
695 (H, ExH, 7),
696 (I, ExI, 8)
697);
698impl_extend_tuple!(
699 (A, ExA, 0),
700 (B, ExB, 1),
701 (C, ExC, 2),
702 (D, ExD, 3),
703 (E, ExE, 4),
704 (F, ExF, 5),
705 (G, ExG, 6),
706 (H, ExH, 7),
707 (I, ExI, 8),
708 (J, ExJ, 9)
709);
710impl_extend_tuple!(
711 (A, ExA, 0),
712 (B, ExB, 1),
713 (C, ExC, 2),
714 (D, ExD, 3),
715 (E, ExE, 4),
716 (F, ExF, 5),
717 (G, ExG, 6),
718 (H, ExH, 7),
719 (I, ExI, 8),
720 (J, ExJ, 9),
721 (K, ExK, 10)
722);
723impl_extend_tuple!(
724 (A, ExA, 0),
725 (B, ExB, 1),
726 (C, ExC, 2),
727 (D, ExD, 3),
728 (E, ExE, 4),
729 (F, ExF, 5),
730 (G, ExG, 6),
731 (H, ExH, 7),
732 (I, ExI, 8),
733 (J, ExJ, 9),
734 (K, ExK, 10),
735 (L, ExL, 11)
736);