Skip to content

Commit d1e444d

Browse files
committed
impl<T> FromIterator<T> for ()
1 parent 2b42625 commit d1e444d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

library/core/src/unit.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use crate::iter::FromIterator;
22

3-
/// Collapses all unit items from an iterator into one.
3+
/// Drains all items from an iterator.
44
///
5-
/// This is more useful when combined with higher-level abstractions, like
6-
/// collecting to a `Result<(), E>` where you only care about errors:
5+
/// This is useful to run an iterator to completion when you don't
6+
/// care about the result, or to collect into a `Result<(), E>` when
7+
/// you only care about errors:
78
///
89
/// ```
910
/// use std::io::*;
@@ -14,8 +15,8 @@ use crate::iter::FromIterator;
1415
/// assert!(res.is_ok());
1516
/// ```
1617
#[stable(feature = "unit_from_iter", since = "1.23.0")]
17-
impl FromIterator<()> for () {
18-
fn from_iter<I: IntoIterator<Item = ()>>(iter: I) -> Self {
19-
iter.into_iter().for_each(|()| {})
18+
impl<T> FromIterator<T> for () {
19+
fn from_iter<A: IntoIterator<Item = T>>(iter: A) -> Self {
20+
iter.into_iter().for_each(|_| {})
2021
}
2122
}

0 commit comments

Comments
 (0)