core/iter/traits/collect.rs
1#[cfg(not(feature = "ferrocene_certified"))]
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 #[stable(feature = "rust1", since = "1.0.0")]
286 type Item;
287
288 /// Which kind of iterator are we turning this into?
289 #[stable(feature = "rust1", since = "1.0.0")]
290 type IntoIter: Iterator<Item = Self::Item>;
291
292 /// Creates an iterator from a value.
293 ///
294 /// See the [module-level documentation] for more.
295 ///
296 /// [module-level documentation]: crate::iter
297 ///
298 /// # Examples
299 ///
300 /// ```
301 /// let v = [1, 2, 3];
302 /// let mut iter = v.into_iter();
303 ///
304 /// assert_eq!(Some(1), iter.next());
305 /// assert_eq!(Some(2), iter.next());
306 /// assert_eq!(Some(3), iter.next());
307 /// assert_eq!(None, iter.next());
308 /// ```
309 #[lang = "into_iter"]
310 #[stable(feature = "rust1", since = "1.0.0")]
311 fn into_iter(self) -> Self::IntoIter;
312}
313
314#[stable(feature = "rust1", since = "1.0.0")]
315impl<I: Iterator> IntoIterator for I {
316 type Item = I::Item;
317 type IntoIter = I;
318
319 #[inline]
320 fn into_iter(self) -> I {
321 self
322 }
323}
324
325/// Extend a collection with the contents of an iterator.
326///
327/// Iterators produce a series of values, and collections can also be thought
328/// of as a series of values. The `Extend` trait bridges this gap, allowing you
329/// to extend a collection by including the contents of that iterator. When
330/// extending a collection with an already existing key, that entry is updated
331/// or, in the case of collections that permit multiple entries with equal
332/// keys, that entry is inserted.
333///
334/// # Examples
335///
336/// Basic usage:
337///
338/// ```
339/// // You can extend a String with some chars:
340/// let mut message = String::from("The first three letters are: ");
341///
342/// message.extend(&['a', 'b', 'c']);
343///
344/// assert_eq!("abc", &message[29..32]);
345/// ```
346///
347/// Implementing `Extend`:
348///
349/// ```
350/// // A sample collection, that's just a wrapper over Vec<T>
351/// #[derive(Debug)]
352/// struct MyCollection(Vec<i32>);
353///
354/// // Let's give it some methods so we can create one and add things
355/// // to it.
356/// impl MyCollection {
357/// fn new() -> MyCollection {
358/// MyCollection(Vec::new())
359/// }
360///
361/// fn add(&mut self, elem: i32) {
362/// self.0.push(elem);
363/// }
364/// }
365///
366/// // since MyCollection has a list of i32s, we implement Extend for i32
367/// impl Extend<i32> for MyCollection {
368///
369/// // This is a bit simpler with the concrete type signature: we can call
370/// // extend on anything which can be turned into an Iterator which gives
371/// // us i32s. Because we need i32s to put into MyCollection.
372/// fn extend<T: IntoIterator<Item=i32>>(&mut self, iter: T) {
373///
374/// // The implementation is very straightforward: loop through the
375/// // iterator, and add() each element to ourselves.
376/// for elem in iter {
377/// self.add(elem);
378/// }
379/// }
380/// }
381///
382/// let mut c = MyCollection::new();
383///
384/// c.add(5);
385/// c.add(6);
386/// c.add(7);
387///
388/// // let's extend our collection with three more numbers
389/// c.extend(vec![1, 2, 3]);
390///
391/// // we've added these elements onto the end
392/// assert_eq!("MyCollection([5, 6, 7, 1, 2, 3])", format!("{c:?}"));
393/// ```
394#[stable(feature = "rust1", since = "1.0.0")]
395pub trait Extend<A> {
396 /// Extends a collection with the contents of an iterator.
397 ///
398 /// As this is the only required method for this trait, the [trait-level] docs
399 /// contain more details.
400 ///
401 /// [trait-level]: Extend
402 ///
403 /// # Examples
404 ///
405 /// ```
406 /// // You can extend a String with some chars:
407 /// let mut message = String::from("abc");
408 ///
409 /// message.extend(['d', 'e', 'f'].iter());
410 ///
411 /// assert_eq!("abcdef", &message);
412 /// ```
413 #[stable(feature = "rust1", since = "1.0.0")]
414 fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T);
415
416 /// Extends a collection with exactly one element.
417 #[unstable(feature = "extend_one", issue = "72631")]
418 fn extend_one(&mut self, item: A) {
419 self.extend(Some(item));
420 }
421
422 /// Reserves capacity in a collection for the given number of additional elements.
423 ///
424 /// The default implementation does nothing.
425 #[unstable(feature = "extend_one", issue = "72631")]
426 fn extend_reserve(&mut self, additional: usize) {
427 let _ = additional;
428 }
429
430 /// Extends a collection with one element, without checking there is enough capacity for it.
431 ///
432 /// # Safety
433 ///
434 /// **For callers:** This must only be called when we know the collection has enough capacity
435 /// to contain the new item, for example because we previously called `extend_reserve`.
436 ///
437 /// **For implementors:** For a collection to unsafely rely on this method's safety precondition (that is,
438 /// invoke UB if they are violated), it must implement `extend_reserve` correctly. In other words,
439 /// callers may assume that if they `extend_reserve`ed enough space they can call this method.
440 // This method is for internal usage only. It is only on the trait because of specialization's limitations.
441 #[unstable(feature = "extend_one_unchecked", issue = "none")]
442 #[doc(hidden)]
443 unsafe fn extend_one_unchecked(&mut self, item: A)
444 where
445 Self: Sized,
446 {
447 self.extend_one(item);
448 }
449}
450
451#[stable(feature = "extend_for_unit", since = "1.28.0")]
452#[cfg(not(feature = "ferrocene_certified"))]
453impl Extend<()> for () {
454 fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T) {
455 iter.into_iter().for_each(drop)
456 }
457 fn extend_one(&mut self, _item: ()) {}
458}
459
460/// This trait is implemented for tuples up to twelve items long. The `impl`s for
461/// 1- and 3- through 12-ary tuples were stabilized after 2-tuples, in 1.85.0.
462#[doc(fake_variadic)] // the other implementations are below.
463#[stable(feature = "extend_for_tuple", since = "1.56.0")]
464#[cfg(not(feature = "ferrocene_certified"))]
465impl<T, ExtendT> Extend<(T,)> for (ExtendT,)
466where
467 ExtendT: Extend<T>,
468{
469 /// Allows to `extend` a tuple of collections that also implement `Extend`.
470 ///
471 /// See also: [`Iterator::unzip`]
472 ///
473 /// # Examples
474 /// ```
475 /// // Example given for a 2-tuple, but 1- through 12-tuples are supported
476 /// let mut tuple = (vec![0], vec![1]);
477 /// tuple.extend([(2, 3), (4, 5), (6, 7)]);
478 /// assert_eq!(tuple.0, [0, 2, 4, 6]);
479 /// assert_eq!(tuple.1, [1, 3, 5, 7]);
480 ///
481 /// // also allows for arbitrarily nested tuples as elements
482 /// let mut nested_tuple = (vec![1], (vec![2], vec![3]));
483 /// nested_tuple.extend([(4, (5, 6)), (7, (8, 9))]);
484 ///
485 /// let (a, (b, c)) = nested_tuple;
486 /// assert_eq!(a, [1, 4, 7]);
487 /// assert_eq!(b, [2, 5, 8]);
488 /// assert_eq!(c, [3, 6, 9]);
489 /// ```
490 fn extend<I: IntoIterator<Item = (T,)>>(&mut self, iter: I) {
491 self.0.extend(iter.into_iter().map(|t| t.0));
492 }
493
494 fn extend_one(&mut self, item: (T,)) {
495 self.0.extend_one(item.0)
496 }
497
498 fn extend_reserve(&mut self, additional: usize) {
499 self.0.extend_reserve(additional)
500 }
501
502 unsafe fn extend_one_unchecked(&mut self, item: (T,)) {
503 // SAFETY: the caller guarantees all preconditions.
504 unsafe { self.0.extend_one_unchecked(item.0) }
505 }
506}
507
508/// This implementation turns an iterator of tuples into a tuple of types which implement
509/// [`Default`] and [`Extend`].
510///
511/// This is similar to [`Iterator::unzip`], but is also composable with other [`FromIterator`]
512/// implementations:
513///
514/// ```rust
515/// # fn main() -> Result<(), core::num::ParseIntError> {
516/// let string = "1,2,123,4";
517///
518/// // Example given for a 2-tuple, but 1- through 12-tuples are supported
519/// let (numbers, lengths): (Vec<_>, Vec<_>) = string
520/// .split(',')
521/// .map(|s| s.parse().map(|n: u32| (n, s.len())))
522/// .collect::<Result<_, _>>()?;
523///
524/// assert_eq!(numbers, [1, 2, 123, 4]);
525/// assert_eq!(lengths, [1, 1, 3, 1]);
526/// # Ok(()) }
527/// ```
528#[doc(fake_variadic)] // the other implementations are below.
529#[stable(feature = "from_iterator_for_tuple", since = "1.79.0")]
530#[cfg(not(feature = "ferrocene_certified"))]
531impl<T, ExtendT> FromIterator<(T,)> for (ExtendT,)
532where
533 ExtendT: Default + Extend<T>,
534{
535 fn from_iter<Iter: IntoIterator<Item = (T,)>>(iter: Iter) -> Self {
536 let mut res = ExtendT::default();
537 res.extend(iter.into_iter().map(|t| t.0));
538 (res,)
539 }
540}
541
542/// An implementation of [`extend`](Extend::extend) that calls `extend_one` or
543/// `extend_one_unchecked` for each element of the iterator.
544#[cfg(not(feature = "ferrocene_certified"))]
545fn default_extend<ExtendT, I, T>(collection: &mut ExtendT, iter: I)
546where
547 ExtendT: Extend<T>,
548 I: IntoIterator<Item = T>,
549{
550 // Specialize on `TrustedLen` and call `extend_one_unchecked` where
551 // applicable.
552 trait SpecExtend<I> {
553 fn extend(&mut self, iter: I);
554 }
555
556 // Extracting these to separate functions avoid monomorphising the closures
557 // for every iterator type.
558 fn extender<ExtendT, T>(collection: &mut ExtendT) -> impl FnMut(T) + use<'_, ExtendT, T>
559 where
560 ExtendT: Extend<T>,
561 {
562 move |item| collection.extend_one(item)
563 }
564
565 unsafe fn unchecked_extender<ExtendT, T>(
566 collection: &mut ExtendT,
567 ) -> impl FnMut(T) + use<'_, ExtendT, T>
568 where
569 ExtendT: Extend<T>,
570 {
571 // SAFETY: we make sure that there is enough space at the callsite of
572 // this function.
573 move |item| unsafe { collection.extend_one_unchecked(item) }
574 }
575
576 impl<ExtendT, I, T> SpecExtend<I> for ExtendT
577 where
578 ExtendT: Extend<T>,
579 I: Iterator<Item = T>,
580 {
581 default fn extend(&mut self, iter: I) {
582 let (lower_bound, _) = iter.size_hint();
583 if lower_bound > 0 {
584 self.extend_reserve(lower_bound);
585 }
586
587 iter.for_each(extender(self))
588 }
589 }
590
591 impl<ExtendT, I, T> SpecExtend<I> for ExtendT
592 where
593 ExtendT: Extend<T>,
594 I: TrustedLen<Item = T>,
595 {
596 fn extend(&mut self, iter: I) {
597 let (lower_bound, upper_bound) = iter.size_hint();
598 if lower_bound > 0 {
599 self.extend_reserve(lower_bound);
600 }
601
602 if upper_bound.is_none() {
603 // We cannot reserve more than `usize::MAX` items, and this is likely to go out of memory anyway.
604 iter.for_each(extender(self))
605 } else {
606 // SAFETY: We reserve enough space for the `size_hint`, and the iterator is
607 // `TrustedLen` so its `size_hint` is exact.
608 iter.for_each(unsafe { unchecked_extender(self) })
609 }
610 }
611 }
612
613 SpecExtend::extend(collection, iter.into_iter());
614}
615
616// Implements `Extend` and `FromIterator` for tuples with length larger than one.
617macro_rules! impl_extend_tuple {
618 ($(($ty:tt, $extend_ty:tt, $index:tt)),+) => {
619 #[doc(hidden)]
620 #[stable(feature = "extend_for_tuple", since = "1.56.0")]
621 #[cfg(not(feature = "ferrocene_certified"))]
622 impl<$($ty,)+ $($extend_ty,)+> Extend<($($ty,)+)> for ($($extend_ty,)+)
623 where
624 $($extend_ty: Extend<$ty>,)+
625 {
626 fn extend<T: IntoIterator<Item = ($($ty,)+)>>(&mut self, iter: T) {
627 default_extend(self, iter)
628 }
629
630 fn extend_one(&mut self, item: ($($ty,)+)) {
631 $(self.$index.extend_one(item.$index);)+
632 }
633
634 fn extend_reserve(&mut self, additional: usize) {
635 $(self.$index.extend_reserve(additional);)+
636 }
637
638 unsafe fn extend_one_unchecked(&mut self, item: ($($ty,)+)) {
639 // SAFETY: Those are our safety preconditions, and we correctly forward `extend_reserve`.
640 unsafe {
641 $(self.$index.extend_one_unchecked(item.$index);)+
642 }
643 }
644 }
645
646 #[doc(hidden)]
647 #[stable(feature = "from_iterator_for_tuple", since = "1.79.0")]
648 #[cfg(not(feature = "ferrocene_certified"))]
649 impl<$($ty,)+ $($extend_ty,)+> FromIterator<($($ty,)+)> for ($($extend_ty,)+)
650 where
651 $($extend_ty: Default + Extend<$ty>,)+
652 {
653 fn from_iter<Iter: IntoIterator<Item = ($($ty,)+)>>(iter: Iter) -> Self {
654 let mut res = Self::default();
655 res.extend(iter);
656 res
657 }
658 }
659 };
660}
661
662impl_extend_tuple!((A, ExA, 0), (B, ExB, 1));
663impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2));
664impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2), (D, ExD, 3));
665impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2), (D, ExD, 3), (E, ExE, 4));
666impl_extend_tuple!((A, ExA, 0), (B, ExB, 1), (C, ExC, 2), (D, ExD, 3), (E, ExE, 4), (F, ExF, 5));
667impl_extend_tuple!(
668 (A, ExA, 0),
669 (B, ExB, 1),
670 (C, ExC, 2),
671 (D, ExD, 3),
672 (E, ExE, 4),
673 (F, ExF, 5),
674 (G, ExG, 6)
675);
676impl_extend_tuple!(
677 (A, ExA, 0),
678 (B, ExB, 1),
679 (C, ExC, 2),
680 (D, ExD, 3),
681 (E, ExE, 4),
682 (F, ExF, 5),
683 (G, ExG, 6),
684 (H, ExH, 7)
685);
686impl_extend_tuple!(
687 (A, ExA, 0),
688 (B, ExB, 1),
689 (C, ExC, 2),
690 (D, ExD, 3),
691 (E, ExE, 4),
692 (F, ExF, 5),
693 (G, ExG, 6),
694 (H, ExH, 7),
695 (I, ExI, 8)
696);
697impl_extend_tuple!(
698 (A, ExA, 0),
699 (B, ExB, 1),
700 (C, ExC, 2),
701 (D, ExD, 3),
702 (E, ExE, 4),
703 (F, ExF, 5),
704 (G, ExG, 6),
705 (H, ExH, 7),
706 (I, ExI, 8),
707 (J, ExJ, 9)
708);
709impl_extend_tuple!(
710 (A, ExA, 0),
711 (B, ExB, 1),
712 (C, ExC, 2),
713 (D, ExD, 3),
714 (E, ExE, 4),
715 (F, ExF, 5),
716 (G, ExG, 6),
717 (H, ExH, 7),
718 (I, ExI, 8),
719 (J, ExJ, 9),
720 (K, ExK, 10)
721);
722impl_extend_tuple!(
723 (A, ExA, 0),
724 (B, ExB, 1),
725 (C, ExC, 2),
726 (D, ExD, 3),
727 (E, ExE, 4),
728 (F, ExF, 5),
729 (G, ExG, 6),
730 (H, ExH, 7),
731 (I, ExI, 8),
732 (J, ExJ, 9),
733 (K, ExK, 10),
734 (L, ExL, 11)
735);