Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f804297

Browse files
committedJan 30, 2023
Implement FromIterator<(AE, BE)> for (impl Default+Extend<AE>, impl Default+Extend<BE>)
1 parent f55b002 commit f804297

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

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

+14
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ pub trait FromIterator<A>: Sized {
141141
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
142142
}
143143

144+
#[stable(feature = "from_iterator_for_tuple", since = "CURRENT_RUSTC_VERSION")]
145+
impl<A, B, AE, BE> FromIterator<(AE, BE)> for (A, B)
146+
where
147+
A: Default + Extend<AE>,
148+
B: Default + Extend<BE>,
149+
{
150+
fn from_iter<I: IntoIterator<Item = (AE, BE)>>(iter: I) -> Self {
151+
let mut res = <(A, B)>::default();
152+
res.extend(iter);
153+
154+
res
155+
}
156+
}
157+
144158
/// Conversion into an [`Iterator`].
145159
///
146160
/// By implementing `IntoIterator` for a type, you define how it will be

0 commit comments

Comments
 (0)
Failed to load comments.